Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

loop and abap code help

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.


Not what you were looking for? View more on this topic or Ask a question