Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine multiple internal table into one final internal table without header line and joins?

thisispankaj
Explorer
0 Kudos
352

Hello experts,

I am stuck at a place where I am able to pull out the data from 5 different tables but not able to put all the data into one final internal table without a header line for the creation of the ALV report? Those five tables are- KNA1, VBRK, VBRP, MARA & MAKT.

KNA1- Customer no(kunnr), Name1(name1), City(Ort01), Company code(Bukrs), Date of record(Erdat), Name of person(Ernam).

VBRK- Customer no(Kunag), Billing document(Vbeln), Billing type(Fkart), Customer group(Kdgrp).

VBRP- Billing document(Vbeln), Material Number(Matnr), Billing item(Posnr).

MARA- Material Number(Matnr), Material group(Matkl), Material type(Mtart).

MAKT- Material Number(Matnr), Material description(Maktx).

On the basis of customer no I have to find a billing document, based on the billing document I need its material number, based on material number need its material group, and based on the material number the material description.

I am able to pull out the data, the only help I want is to put all these internal tables data into one final internal table which is.

BEGIN OF TP_FINAL,
KUNNR TYPE KUNNR,
NAME1 TYPE NAME1,
ORT01 TYPE ORT01,
BUKRS TYPE BUKRS,
ERDAT TYPE ERDAT,
ERNAM TYPE ERNAM,
VBELN TYPE VBELN,
FKART TYPE FKART,
FKTYP TYPE FKTYP,
KDGRP TYPE KDGRP,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
MATKL TYPE MATKL,
MTART TYPE MTART,
MAKTX TYPE MAKTX,
MAKTG TYPE MAKTG,
END OF TP_FINAL.

Please help me out with this?

7 REPLIES 7

basantmhr
Participant
213

Can you share more about the table from which you are fetching the data, also Do all the 5 tables have some kind of relationship? and how exactly you want to have the data in the internal table

raymond_giuseppi
Active Contributor
0 Kudos
213

Use Fields symbols, so no header line required (sample)

  LOOP AT itab1 ASSIGNING <fs1>. " use the table with the more records.
    APPEND INITIAL LINE TO itab2 ASSIGNING <fs2>. 
    MOVE-CORRESPONDING <fs1> TO <fs2>.
    READ TABLE itab3 WITH KEY field2 = <fs2>-field2 ASSIGNING <fs3>. " sorted type table so binary search explicit of course...
    <fs2>-field3 = <fs3>-field3.
    " ...
  ENDLOOP.<br>

Of course, fell free to use 7.40+ syntax for internal table.

What did you already code?

VXLozano
Active Contributor
0 Kudos
213

Did you tried a JOIN?

thisispankaj
Explorer
0 Kudos
213

Hello, yes I tried with join and it's working but I have to try it in another way which is by loops, read tables, and multiple select queries, and then populating the final internal table.

VXLozano
Active Contributor
0 Kudos
213

I'm sorry, but I cannot understand why you cannot use JOINs. This is weird.

matt
Active Contributor
213

vicen.lozano Home work question.

VXLozano
Active Contributor
0 Kudos
213

It's what I thought, matthew.billingham . Sadly, that's the worst way to "learn" anything. And I cannot waste more time training someone now.