Skip to Content
author's profile photo Former Member
Former Member

Internal Table Problem

Hi All,

I am having 9 internal tables as posted below with different fields, and one final internal table which contains all the fields containd by the 9 internal tables,

I want to append the data of the 9 internal tables to the final internal table ,

suggest what is the way or I have to change the fields in the internal table.

DATA:BEGIN OF it_stpo OCCURS 0,

menge LIKE stpo-menge,

postp LIKE stpo-postp,

meins LIKE stpo-meins,

aennr LIKE stpo-aennr,

pswrk LIKE stpo-pswrk,

stlnr LIKE stpo-stlnr,

stlkn LIKE stpo-stlkn,

END OF it_stpo.

DATA:BEGIN OF it_makt OCCURS 0,

maktx LIKE makt-maktx,

matnr LIKE makt-matnr,

END OF it_makt.

DATA:BEGIN OF it_mast OCCURS 0,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

stlal LIKE mast-stlal,

stlnr LIKE mast-stlnr,

andat LIKE mast-andat,

annam LIKE mast-annam,

totprc TYPE i,

END OF it_mast.

DATA:BEGIN OF it_marc OCCURS 0,

lgpro LIKE marc-lgpro,

matnr LIKE marc-matnr,

beskz LIKE marc-beskz,

END OF it_marc.

DATA:BEGIN OF it_mkol OCCURS 0,

slabs LIKE mkol-slabs,

matnr LIKE mkol-matnr,

sinsm LIKE mkol-sinsm,

END OF it_mkol.

DATA: BEGIN OF it_mbew OCCURS 0,

stprs LIKE mbew-stprs,

matnr LIKE mbew-matnr,

verpr LIKE mbew-verpr,

peinh LIKE mbew-peinh,

vmvpr LIKE mbew-vmvpr,

bwkey LIKE mbew-bwkey,

END OF it_mbew.

DATA:BEGIN OF it_mard OCCURS 0,

labst LIKE mard-labst,

matnr LIKE mard-matnr,

lgort LIKE mard-lgort,

insme LIKE mard-insme,

END OF it_mard.

DATA:BEGIN OF it_eord OCCURS 0,

lifnr LIKE eord-lifnr,

END OF it_eord.

DATA:BEGIN OF it_plpo OCCURS 0,

vgw03 LIKE plpo-vgw03,

END OF it_plpo.

DATA:BEGIN OF it_final OCCURS 0 ,

menge LIKE stpo-menge,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

postp LIKE stpo-postp,

meins LIKE stpo-meins,

aennr LIKE stpo-aennr,

pswrk LIKE stpo-pswrk,

vgw03 LIKE plpo-vgw03,

lifnr LIKE eord-lifnr,

labst LIKE mard-labst,

lgort LIKE mard-lgort,

insme LIKE mard-insme,

stprs LIKE mbew-stprs,

verpr LIKE mbew-verpr,

peinh LIKE mbew-peinh,

stlal LIKE mast-stlal,

vmvpr LIKE mbew-vmvpr,

bwkey LIKE mbew-bwkey,

slabs LIKE mkol-slabs,

sinsm LIKE mkol-sinsm,

lgpro LIKE marc-lgpro,

beskz LIKE marc-beskz,

stlnr LIKE stpo-stlnr,

totprc TYPE i,

stlkn LIKE stpo-stlkn,

END OF it_final.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 05:39 PM

    Hi,

    1. Loop one of the main tables.

    2. Read all the remaining 8 tables based on some key field from the first table.

    3. Assign all fields for all teh tables to the work area of the final table.

    3. Once you get all the data in work area, append that work area to the final table.

    Reward points if the answer is helpful.

    Regards,

    Mukul

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Rahul,

      Your problem looks different as people are explaining something different.

      Let me explain it .

      1. First of all you have to find the relationship among the tables with their key fields.

      As in your case i have analysed that the table 'it_eord' contain only one field 'lifnr' and another table contain 'it_plpo' contain 'vgw03'. which are not present in any other table which you defined ( not talking about your final table).

      As a result you can't insert these value into the final internal table. either you have to add one more field in the above internal table which are present in any table or you add lifnr and vgw03 field in any other table except 'it_eord' and 'it_plpo' .

      Then loop on one table and read the content from the other table with their keys and populate the data into the Final table.

      Thanks,

      Chidanand.

      PS: Try to create a realtionship among all the table and then proceed.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 05:30 PM

    to append all into final one...u need to do a loop at one internal table...and read all other internal tables so that u can append the final data...try to put primary keys of all 8 tables in the first one so that u can loop first one and use read for all other 8.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 05:32 PM

    Hi

    In order to merge the data into a single internal table, use the following steps;

    1. Identify the key fields (same fields in different internal tables).

    2. Loop at one of those internal tables

    3. Use the READ statement.

    This should solve the problem.

    PLZ REWARD POINTS

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 05:32 PM

    Hi,

    What are the key fields in those tables ? Because to compile data from 9 tables into a single table, you will need some key fields which will be used to match the data from different tables.

    Regards,

    Mukul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 05:33 PM

    From a logical perspective, there is not a common field between all 9 tables. I would expect to find MATNR in all 9; and it does not exist.

    How do you plan to have data consistency / "balance" with different objects?

    What is your business goal?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 06:12 PM

    Hi,

    Put some Common field in these tables also then only you can follow other steps of Looping at one internal table and then reading other tables and filling the final internal table.

    it_stpo

    it_eord

    it_plpo

    The common field in other tables is MATNR.

    Regards,

    Aman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2007 at 06:40 PM

    Rahul,

    I think that everyone has clarified your design flaw well enough, and provided options once the flaw is addressed.

    Please reward points accordingly and close this thread.

    Thanks in advance.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 13, 2007 at 03:37 AM

    Hi,

    I've a similar code of my program as follows:

    SELECT QMNUM

    IWERK

    EQUNR

    BTPLN

    AUSWK

    INGRP

    QMDAB

    BEZDT

    TPLNR

    SWERK

    MSGRP

    FROM VIQMEL INTO TABLE ITABMEL

    WHERE IWERK = 'M011' and

    AUSWK = 'A' and

    INGRP = 'SLM' and

    QMDAB NE '00000000' and

    BEZDT GE SDATE-LOW and BEZDT LE SDATE-HIGH and

    SWERK IN S_WERK.

    IF SY-SUBRC = 0.

    SELECT QMNUM MNGRP MNCOD FROM QMMA

    INTO CORRESPONDING FIELDS OF TABLE ITABMA

    FOR ALL ENTRIES IN ITABMEL

    WHERE QMNUM = ITABMEL-QMNUM and

    MNGRP = 'RESTLT01' and

    MNCOD = '0350'.

    SORT ITABMA BY QMNUM.

    LOOP AT ITABMEL.

    READ TABLE ITABMA WITH KEY QMNUM = ITABMEL-QMNUM BINARY

    SEARCH.

    IF SY-SUBRC = 0.

    MOVE-CORRESPONDING ITABMA TO ITABMEL.

    MODIFY ITABMEL TRANSPORTING QMNUM.

    ENDIF.

    ENDLOOP.

    SELECT TPLNR PLTXT FROM IFLO

    INTO CORRESPONDING FIELDS OF TABLE ITABLO

    FOR ALL ENTRIES IN ITABMEL

    WHERE TPLNR = ITABMEL-TPLNR.

    SORT ITABLO BY TPLNR.

    LOOP AT ITABMEL.

    READ TABLE ITABLO WITH KEY TPLNR = ITABMEL-TPLNR BINARY

    SEARCH.

    IF SY-SUBRC = 0.

    MOVE-CORRESPONDING ITABLO TO ITABMEL.

    MODIFY ITABMEL TRANSPORTING PLTXT.

    ENDIF.

    ENDLOOP.

    SELECT QMNUM

    URKAT

    URGRP

    URCOD FROM QMUR

    INTO CORRESPONDING FIELDS OF TABLE ITABMUR

    FOR ALL ENTRIES IN ITABMEL

    WHERE QMNUM = ITABMEL-QMNUM.

    SORT ITABMUR BY QMNUM.

    LOOP AT ITABMEL.

    READ TABLE ITABMUR WITH KEY QMNUM = ITABMEL-QMNUM

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE-CORRESPONDING ITABMUR TO ITABMEL.

    MODIFY ITABMEL TRANSPORTING URKAT URGRP URCOD.

    ENDIF.

    ENDLOOP.

    SELECT KATALOGART

    CODEGRUPPE

    CODE

    KURZTEXT FROM QPCT

    INTO CORRESPONDING FIELDS OF TABLE ITABPCT

    FOR ALL ENTRIES IN ITABMEL

    WHERE KATALOGART = ITABMEL-URKAT and

    CODEGRUPPE = ITABMEL-URGRP and

    CODE = ITABMEL-URCOD.

    SORT ITABPCT BY KATALOGART CODEGRUPPE CODE.

    LOOP AT ITABMEL.

    READ TABLE ITABPCT WITH KEY KATALOGART = ITABMEL-URKAT

    CODEGRUPPE = ITABMEL-URGRP

    CODE = ITABMEL-URCOD

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE-CORRESPONDING ITABPCT TO ITABMEL.

    MODIFY ITABMEL TRANSPORTING KURZTEXT.

    ENDIF.

    ENDLOOP.

    SELECT OBJEK ATINN ATFLV FROM AUSP

    INTO CORRESPONDING FIELDS OF TABLE ITABUSP

    FOR ALL ENTRIES IN ITABMEL

    WHERE OBJEK = ITABMEL-EQUNR and

    ATINN = '0000000190'.

    SORT ITABUSP BY OBJEK.

    LOOP AT ITABMEL.

    READ TABLE ITABUSP WITH KEY OBJEK = ITABMEL-EQUNR

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE ITABUSP-ATFLV TO ITABMEL-ATFLV1.

    MODIFY ITABMEL TRANSPORTING ATFLV1.

    ENDIF.

    CLEAR ITABUSP.

    ENDLOOP.

    SELECT OBJEK ATINN ATWRT FROM AUSP

    INTO CORRESPONDING FIELDS OF TABLE ITABWRT

    FOR ALL ENTRIES IN ITABMEL

    WHERE OBJEK = ITABMEL-EQUNR and

    ATINN = '0000000191'.

    SORT ITABWRT BY OBJEK.

    LOOP AT ITABMEL.

    READ TABLE ITABWRT WITH KEY OBJEK = ITABMEL-EQUNR

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE ITABWRT-ATWRT TO ITABMEL-ATWRT2.

    MODIFY ITABMEL TRANSPORTING ATWRT2.

    ENDIF.

    CLEAR ITABWRT.

    ENDLOOP.

    SELECT OBJEK ATINN ATFLV FROM AUSP

    INTO CORRESPONDING FIELDS OF TABLE ITABUSP

    FOR ALL ENTRIES IN ITABMEL

    WHERE OBJEK = ITABMEL-EQUNR and

    ATINN = '0000000193'.

    SORT ITABUSP BY OBJEK.

    LOOP AT ITABMEL.

    READ TABLE ITABUSP WITH KEY OBJEK = ITABMEL-EQUNR

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE ITABUSP-ATFLV TO ITABMEL-ATFLV3.

    MODIFY ITABMEL TRANSPORTING ATFLV3.

    ENDIF.

    CLEAR ITABUSP.

    ENDLOOP.

    SELECT OBJEK ATINN ATWRT FROM AUSP

    INTO CORRESPONDING FIELDS OF TABLE ITABWRT

    FOR ALL ENTRIES IN ITABMEL

    WHERE OBJEK = ITABMEL-EQUNR and

    ATINN = '0000000194'.

    SORT ITABWRT BY OBJEK.

    LOOP AT ITABMEL.

    READ TABLE ITABWRT WITH KEY OBJEK = ITABMEL-EQUNR

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE ITABWRT-ATWRT TO ITABMEL-ATWRT4.

    MODIFY ITABMEL TRANSPORTING ATWRT4.

    ENDIF.

    CLEAR ITABWRT.

    ENDLOOP.

    Hope it helps.

    Reward if helpful.

    Regards,

    Sipra

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.