12-21-2014 9:58 PM
i am new in ABAP development. i want to show tax value instead tax code.I use this Table A003, KONP, EKPO ,RSEG.
Help me READ TABLE inside loop. i use this correct or not. otherwise give me altternate way of this code.
PARAMETERS : P_EBELN TYPE EBELN
.
TYPES : BEGIN OF TY_FINAL,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE RSEG-MATNR,
TXZ01 TYPE EKPO-TXZ01,
IDLNF TYPE EKPO-IDNLF,
BPMNG TYPE RSEG-BPMNG,
MWSKZ TYPE RSEG-MWSKZ,
VALUE TYPE KBETR_KOND,
END OF TY_FINAL.
TYPES : BEGIN OF IT_TAX,
CODE TYPE MWSKZ,
TAX TYPE KONP-KBETR,
VALUE TYPE KBETR_KOND,
END OF IT_TAX.
DATA IT_T TYPE TABLE OF IT_TAX.
DATA WT_T TYPE IT_TAX.
DATA IT_final TYPE TABLE OF TY_final .
DATA WA_final TYPE TY_final.
SELECT * FROM A003 INTO TABLE IT_A3.
SELECT * FROM KONP INTO TABLE IT_KP
FOR ALL ENTRIES IN IT_A3
WHERE KNUMH = IT_A3-KNUMH.
LOOP AT IT_A3 INTO WT_A3.
READ TABLE IT_KP INTO WT_KP WITH KEY KNUMH = WT_A3-KNUMH.
WT_T-CODE = WT_A3-MWSKZ.
WT_T-TAX = WT_KP-KBETR.
WT_T-VALUE = WT_KP-KBETR / 10.
APPEND WT_T TO IT_T.
ENDLOOP.
SELECT * FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN = P_EBELN.
SELECT * FROM RSEG INTO TABLE It_RSEG
FOR ALL ENTRIES IN IT_EKpO
WHERE EBELN = IT_EKpO-EBELN
AND EBELP = IT_EKpO-EBELP.
LOOP AT IT_RSEG INTO WA_RSEG.
READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_RSEG-EBELN EBELP = WA_RSEG-EBELP .
READ TABLE IT_T INTO WT_T WITH KEY CODE = WA_RSEG-MWSKZ
wa_final-ebeln = wa_ekpo-ebeln.
wa_final-ebelp = wa_ekpo-ebelp.
wa_final-matnr = wa_rseg-matnr.
WA_FINAL-TXZ01 = WA_EKPO-TXZ01.
wa_final-IDLNF = wa_ekpo-IDNLF.
wa_final-BPMNG = wa_rseg-BPMNG.
WA_FINAL-MWSKZ = WA_RSEG-MWSKZ.
WA_FINAL-VALUE = WT_T-VALUE.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
12-21-2014 10:47 PM
Do you have an error? Is the code not producing what you expect?
Can you please formulate a more detailed question.
Asking us to just read your (completely uncommented) code is not the right way to use this forum.
cheers
Paul
12-22-2014 12:54 AM
Hi Muhammad,
Always debug your code step by step and check if you want to know if your code is working properly or not. And also follow some coding practices like:
LOOP AT it_a3 INTO wt_a3.
READ TABLE it_kp INTO wt_kp WITH KEY knumh = wt_a3-knumh.
IF sy-subrc = 0.
wt_t-code = wt_a3-mwskz.
wt_t-tax = wt_kp-kbetr.
wt_t-value = wt_kp-kbetr / 10.
APPEND wt_t TO it_t.
CLEAR wt_t.
ENDIF.
ENDLOOP.
Also for better performance you can use binary search in the read operation after sorting the concerned internal table.
12-22-2014 2:10 AM
Hi,
For getting the tax details
Select Query
KONP-KNUMH = EKKO-KNUMV.
Read Statement.
Read it_konp with key knumh = wa_ekko-knumv
kopos = wa_ekpo-ebelp.
Hope it helpful.
Regards,
Venkat.