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: 

Comparing records and Pass records to multiple internal tables

sandeep_gvv2
Participant
0 Kudos

Hello All,

I am working on one of the smartform In this i am facing one of the scenario like

Example : Under one delivery i have multiple materials with HTS CODE(MARC-STAWN) AND INDICATOR(MARC-MOGRU) Of type 'CITIES' OR 'DG'.

Mat1--> MAT1 HTS 123

Mat2 --> MAT2 HTS 123

Mat3 --> MAT3 HTS 234

Mat4 --> MAT4 HTS 234 CITIES

MAT5 --> MAT5 HTS 345 DG

MAT6 --> MAT6 HTS 345 DG

MAT7 --> MAT7 HTS 456 CITIES

It should combine and display as

Proforma 1 : MAT1,MAT2

Proforma 2: MAT3

Proforma 3: MAT4

Proforma 4: MAT5,MAT6

Proforma 5: MAT7

How i need to combine is for suppose in a loop if i have 7 materials,each material has HTS CODE(MARC-STAWN)

and may/may not (MARC-MOGRU) indicator(CITIES/DG).

I need to check like for example for Mat1 have HTS CODE as HTS 123 we need to check all records in loop first on basis of HTS CODE and indicator field.

Proforma 1 : HTS 123 is having for MAT1 and MAT2 and it don't have any indicator so i am moving this records to one internal table.

Proforma 2,3 : HTS 234 is having for MAT3 ,MAT4 first we need to check hts code is same or not if same we need to check indicator field here it is not same so i am moving MAT3 to Proforma 2 and MAT4 to Proforma 3.

Proforma 4 : Mat 5,6 have same HTS CODE and same indicator of type DG so i am moving MAT5,6 to Proforma 4

Proforma 5: MAT7 hts code and indicator is not matching with any so moving MAT 7 to Proforma 5.

I know it is tricky to say it simple in a loop need to check for each material with HTS CODE and indicator accordingly need to move to seperate proformas.

Currently i am planning to move each proformas to internal tables but there is no limitations on number of proformas so can i use dynamic internal tables if so how to use it?

Based on number of proformas in smartform output i need to get that many pages with related materials like if we have 5 proformas we need to have 5 pages with related materials of their proformas.

Can any one help me on this i am trying for last four days but i am now able to crack it...

6 REPLIES 6

raymond_giuseppi
Active Contributor

Why don't you SORT (or use a sorted type table) on HTS and INDICATOR then in a LOOP process a single 'proforma' between AT NEW (new page, clear total) and AT END OF statements (end of page, total)

Alt: use new itab syntax from 7.40 ...

0 Kudos

Thanks for the reply sir can you explain in detail and can i use dynamic internal tables to store multiple proformas and how can i trigger multiple pages for multiple proformas in smartform?

0 Kudos

(I will reformulate my answer)

You don't need any 'dynamic' internal table, just sort the one internal table and manage the records in one loop...

In an Abap/Code node or driver program SORT itab BY field1 field2.
In a LOOP node
- Event for new field2, triggers new-page
- Print detail records
- Event for end of field2, print sum

If you actually wish to use dynamic internal table, you could build an internal table of internal tables.

DoanManhQuynh
Active Contributor
0 Kudos

Depend on what you want there are some options:

1. Using SORT function in smartforms:

https://help.sap.com/doc/saphelp_nw70/7.0.31/en-US/0b/5da4ea2cf511d5b692006094192fe3/content.htm?no_...

2. Sort internal table before send to smartforms: using SORT, GROUP BY...

0 Kudos

Thanks for the reply as you said i can sort the internal table using smartform events or using sort command but after that how can i put up the possible combinations and move to dynamic internal tables and how many dynamic internal tables are there that many pages i need to get in smartform output.

Can you Pls help me on this if u have any idea.

0 Kudos

srikanth javvaji

are you saying you want to group data based on MARC-STAWN and MARC-MOGRU, display each group members in 1 page of smartforms or you want to sumarize the data and display total only?

the combinatons are decided when you sort the data based on the above 2 fields, using smartforms sort function you can set the page break at the end of each group. take a look at demo smartforms: SF_EXAMPLE_03 to understand sort event. and you also can read about page break here:

https://blogs.sap.com/2015/02/24/how-to-set-page-break-page-reset-in-smartforms-using-events