‎2020 Jul 08 3:15 PM
Hi Experts,
I have a requirement where I have a select-options for plant input that can handle ranges.
With plant input, I need to select from multiple tables.
From these tables, I have created internal tables e.g gt_ekpo, gt_eban, gt_marc.
My question is how do I print the output in such a way that it is separated by plant? For example, my input in selection screen is 1110 and 1112.
I want to print it like the below:
Plant 1110
Details from gt_ekpo
Details from gt_eban
Details from gt_marc.
Plant 1112
Details from gt_ekpo
Details from gt_eban
Details from gt_marc.
Thank you.
Regards,
Kath
‎2020 Jul 08 3:19 PM
‎2020 Jul 08 3:35 PM
‎2020 Jul 08 4:20 PM
Hi,
Along with satishkumarbalasubramanian's answer which is right way approach, try by sort based on Plant and loop at .. AT NEW append to tab1 also can help.
‎2020 Jul 10 4:53 PM
Since you already collected all the data in your three tables, gt_ekpo, gt_eban and gt_marc, you could do the following in a loop for your plants, to print out the information:
LOOP AT gt_plants ASSIGNING <plant>. " e.g. select from T001W based on input
WRITE: / <plant>-werks, ' ', <plant>-name1.
LOOP AT gt_ekpo ASSIGNING <ekpo> WHERE werks = <plant>-werks.
" Write details from gt_ekpo
ENDLOOP.
LOOP AT gt_eban ASSIGNING <eban> WHERE werks = <plant>-werks.
" Write details from gt_eban
ENDLOOP.
LOOP AT gt_marc ASSIGNING <marc> WHERE werks = <plant>-werks.
" Write details from gt_ekpo
ENDLOOP.
ENDLOOP.Depending on the amount of selected data, it could be useful to define primary or secondary sorted keys for gt_ekpo, gt_eban and gt_marc, in order to improve the performance when accessing those tables.
If you want to rewrite your select, you could also fetch all the data at once using several joins to combine data from T001W, EKPO, EBAN and MARC, and use the GROUP BY function on the resulting internal table.
LOOP AT it_table INTO DATA(wa).
GROUP BY wa-werks
INTO DATA(key).
LOOP AT GROUP key ASSIGNING FIELD-SYMBOL(<members>).
" collect data based on plant
ENDLOOP.
WRITE: / <members>-werks, ' ', <members>-name1.
" write data collected for plant
ENDLOOP.<br>
‎2020 Oct 09 4:44 AM
kdarunday, do you continue to have issues or were you able to solve your problem?
Please add comments to your question that further describe your problem or add an answer that describes how you solved your problem.
If your problem is solved, accept an answer if it helped you and please close the question.