Hi Experts,
Considering I have 7 fields
1. VKONT
2. DOCX
3. DOCY
4. MIGPR (Migrated_prin)
5. WAIVED_PRIN
6. RECOVERABLE_PRIN
7. CLOSING_PRIN
where DOCX and DOCY are into a 1 : MANY relation.
Formula that I am applying here is - Migrated_Principal - Waived - Recoverable = Closing
How will I get CLOSING_PRIN to become MIGPR for subsequent DOCYs where . e.g is as below.
Current Scenario which I am getting the output for.
CA | DVB_Ref_Num | DVB_Doc | Migrated_Principal | Waived_Principal | Rcvrble_Principal | Closing_Principal |
600043640 | 100330 | 100331 | 8,000.00 | 0 | 800 | 7,200.00 |
600043640 | 100330 | 100361 | 8,000.00 | 0 | 10 | 7,990.00 |
600043640 | 100330 | 100362 | 8,000.00 | 0 | 10 | 7,990.00 |
600043640 | 100330 | 100556 | 8,000.00 | 0 | 0 | 8,000.00 |
Requirement
CA | DVB_Ref_Num | DVB_Doc | Migrated_Principal | Waived_Principal | Rcvrble_Principal | Closing_Principal |
600043640 | 100330 | 100331 | 8,000.00 | 0 | 800 | 7,200.00 |
600043640 | 100330 | 100361 | 7,200.00 | 0 | 10 | 7,190.00 |
600043640 | 100330 | 100362 | 7,190.00 | 0 | 10 | 7,180.00 |
600043640 | 100330 | 100556 | 7,180.00 | 0 | 0 | 7,180.00 |
Appending is my code that I am using
FORM GET_DATA .
SELECT DVBDOC VKONT VKONA OLDKNO LEGAL CSFNO ORGPR ORGLP ORGPRN ORGLPN MIGPR MIGLP MIGAL MIGPRN MIGLPN MIGALN ERDAT
FROM ZCATR_DVBAR INTO CORRESPONDING FIELDS OF TABLE IT_ZCATR_DVBAR WHERE VKONT IN CONT_ACC AND ERDAT IN CREATDON AND DVBST = 'M'.
SORT IT_ZCATR_DVBAR BY DVBDOC ASCENDING.
SELECT DVBDOC VKONT VKONA OLDKNO LEGAL CSFNO ORGPR ORGLP ORGPRN ORGLPN MIGPR MIGLP MIGAL MIGPRN MIGLPN MIGALN DVBREF ERDAT APVR1 APVR2 APVR1_DATE APVR2_DATE DVBST WFSTAT
FROM ZCATR_DVBAR_VW INTO CORRESPONDING FIELDS OF TABLE IT_ZCATR_DVBAR_VW FOR ALL ENTRIES IN IT_ZCATR_DVBAR WHERE DVBREF = IT_ZCATR_DVBAR-DVBDOC .
SORT IT_ZCATR_DVBAR_VW BY VKONT DVBREF DVBDOC ASCENDING.
* BREAK-POINT.
LOOP AT IT_ZCATR_DVBAR_VW INTO WA_ZCATR_DVBAR_VW.
WA_FINAL-DVBST = WA_ZCATR_DVBAR_VW-DVBST.
WA_FINAL-WFSTAT = WA_ZCATR_DVBAR_VW-WFSTAT.
WA_FINAL-DVBREF = WA_ZCATR_DVBAR_VW-DVBREF.
WA_FINAL-DVBDOC = WA_ZCATR_DVBAR_VW-DVBDOC.
WA_FINAL-APVR1 = WA_ZCATR_DVBAR_VW-APVR1.
WA_FINAL-APVR1_DATE = WA_ZCATR_DVBAR_VW-APVR1_DATE.
WA_FINAL-APVR2 = WA_ZCATR_DVBAR_VW-APVR2.
WA_FINAL-APVR2_DATE = WA_ZCATR_DVBAR_VW-APVR2_DATE.
IF WA_ZCATR_DVBAR_VW-DVBST = 'W' AND WA_ZCATR_DVBAR_VW-WFSTAT = 'A'.
WA_FINAL-WAIVED_PRIN = WA_ZCATR_DVBAR_VW-MIGPR.
WA_FINAL-WAIVED_LPSC = WA_ZCATR_DVBAR_VW-MIGLP.
WA_FINAL-WAIVEDACCRLP = WA_ZCATR_DVBAR_VW-MIGAL.
WA_FINAL-WAIVED_NTA_P = WA_ZCATR_DVBAR_VW-MIGPRN.
WA_FINAL-WAIVED_NTA_L = WA_ZCATR_DVBAR_VW-MIGLPN.
WA_FINAL-WAIVED_NTACRLP = WA_ZCATR_DVBAR_VW-MIGALN.
ELSEIF WA_ZCATR_DVBAR_VW-DVBST EQ 'R' AND WA_ZCATR_DVBAR_VW-WFSTAT = 'A'.
WA_FINAL-RECOVERABLE_PRIN = WA_ZCATR_DVBAR_VW-MIGPR.
WA_FINAL-RECOVERABLE_LPSC = WA_ZCATR_DVBAR_VW-MIGLP.
WA_FINAL-RECOVERABLE_ACCRLP = WA_ZCATR_DVBAR_VW-MIGAL.
WA_FINAL-RECOVERABLE_NTA_P = WA_ZCATR_DVBAR_VW-MIGPRN.
WA_FINAL-RECOVERABLE_NTA_L = WA_ZCATR_DVBAR_VW-MIGLPN.
WA_FINAL-RECOVERABLE_NTACRLP = WA_ZCATR_DVBAR_VW-MIGALN.
ENDIF.
READ TABLE IT_ZCATR_DVBAR INTO WA_ZCATR_DVBAR WITH KEY DVBDOC = WA_ZCATR_DVBAR_VW-DVBREF BINARY SEARCH.
IF SY-SUBRC = 0.
WA_FINAL-VKONT = WA_ZCATR_DVBAR-VKONT.
WA_FINAL-VKONA = WA_ZCATR_DVBAR-VKONA.
WA_FINAL-OLDKNO = WA_ZCATR_DVBAR-OLDKNO.
WA_FINAL-ERDAT = WA_ZCATR_DVBAR-ERDAT.
WA_FINAL-LEGAL = WA_ZCATR_DVBAR-LEGAL.
WA_FINAL-CSFNO = WA_ZCATR_DVBAR-CSFNO.
WA_FINAL-ORGPR = WA_ZCATR_DVBAR-ORGPR.
WA_FINAL-ORGLP = WA_ZCATR_DVBAR-ORGLP.
WA_FINAL-ORGPRN = WA_ZCATR_DVBAR-ORGPRN.
WA_FINAL-ORGLPN = WA_ZCATR_DVBAR-ORGLPN.
WA_FINAL-MIGPR = WA_ZCATR_DVBAR-MIGPR.
WA_FINAL-MIGLP = WA_ZCATR_DVBAR-MIGLP.
WA_FINAL-MIGAL = WA_ZCATR_DVBAR-MIGAL.
WA_FINAL-MIGPRN = WA_ZCATR_DVBAR-MIGPRN.
WA_FINAL-MIGLPN = WA_ZCATR_DVBAR-MIGLPN.
WA_FINAL-MIGALN = WA_ZCATR_DVBAR-MIGALN.
ENDIF.
WA_FINAL-CLOSING_PRIN = WA_FINAL-MIGPR - WA_FINAL-WAIVED_PRIN - WA_FINAL-RECOVERABLE_PRIN .
WA_FINAL-CLOSING_LPSC = WA_FINAL-MIGLP - WA_FINAL-WAIVED_LPSC - WA_FINAL-RECOVERABLE_LPSC.
WA_FINAL-CLOSING_ACCRLP = WA_FINAL-MIGAL - WA_FINAL-WAIVEDACCRLP - WA_FINAL-RECOVERABLE_ACCRLP.
WA_FINAL-CLOSING_NTA_P = WA_FINAL-MIGPRN - WA_FINAL-WAIVED_NTA_P - WA_FINAL-RECOVERABLE_NTA_P.
WA_FINAL-CLOSING_NTA_L = WA_FINAL-MIGLPN - WA_FINAL-WAIVED_NTA_L - WA_FINAL-RECOVERABLE_NTA_L.
WA_FINAL-CLOSING_NTACRLP = WA_FINAL-MIGALN - WA_FINAL-WAIVED_NTACRLP - WA_FINAL-RECOVERABLE_NTACRLP.
* SORT IT_COUNT BY VKONT DVBREF DVBDOC ASCENDING.
* APPEND WA_count TO IT_count.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_ZCATR_DVBAR, WA_ZCATR_DVBAR_VW, WA_FINAL.
ENDLOOP.
Please guide.
regards