Skip to Content
0
Former Member
Jan 27, 2010 at 06:12 AM

Problem In Inserting Multiple Values In Ztable

109 Views

Hi,

I had developed a table in which i am inserting the data from the BSEG table and the problem is if there are multiple values wr.t. GL AAccount ID(HKONT) it is picking up only the last value of it as i want to store all of them.

I had searched in SDN first but not able to get the desierd help.

Here is the code which i had developed for it..


Report ztest.

TABLES : BSEG.

TYPES : BEGIN OF ITAB,
        MANDT TYPE BSEG-MANDT ,  "client"
        BUKRS TYPE BSEG-BUKRS,   "company code"
        GJAHR TYPE BSEG-GJAHR,   "fiscal Year"
        HKONT TYPE BSEG-HKONT,   "G/L account No"
        SHKZG TYPE BSEG-SHKZG,   "Debit/ Credit Indicator"
        TAMT   TYPE I,
        END OF ITAB.

DATA : W_ITAB TYPE ITAB ,
       T_ITAB TYPE ITAB OCCURS 0.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
SELECT-OPTIONS : PBUKRS FOR BSEG-BUKRS, PGJAHR FOR BSEG-GJAHR,PVALUT FOR BSEG-VALUT.
SELECTION-SCREEN END OF BLOCK B1.

 DATA  :  BEGIN OF itab1 OCCURS 0.
          INCLUDE STRUCTURE Ztab21.
DATA  :   END OF itab1.

SELECT MANDT BUKRS GJAHR HKONT SHKZG PSWBT
       FROM BSEG
       INTO TABLE itab1
  WHERE BUKRS IN PBUKRS AND GJAHR IN PGJAHR AND VALUT IN PVALUT.

SORT ITAB1 BY HKONT.

LOOP AT ITAB1.

INSERT INTO ZTAB21 VALUES itab1.

WRITE:/ ITAB1-HKONT,ITAB1-SHKZG,ITAB1-TAMT.

ENDLOOP.