‎2020 Nov 05 6:02 AM
Hi,
Hope you and your family are doing good.
I need one control level statement for a requirement I got. But I am not sure of which one i can use.
Requirement: will get the header+item data for a documents into internal table through excel / xls file. For suppose if a document has 5 line items, all the five line item header details must be same. Need to add a validation for that. For example, If we pass three documents, if document one has 2 line items, document two has 3 line items and document three has 3 line items. the sequence of records in the internal table will be as follows. We have one field in the internal table which stores line number,
1
2
1
2
3
1
2
3.
So, here I need to check all the header records document wise, which control statement I can use for this ? Can I use AT END OF line number ? Please suggest me the control level statement that fits for my requirement.
‎2020 Nov 05 7:00 PM
As per my understanding of your question, you just have one column-"Line Number" in your table which identifies when a new document is started by having value 1.
So, you can put a check on this column and use condition-
IF itab-line_No EQ '1'.
...
ENDIF.AT END OF won't work here as it will trigger at each record when line_no value will change which is each record of your loop.
‎2020 Nov 05 10:14 AM
I don't understand neither the starting point nor what you exactly ask.
For the starting point, do you have one internal table like that?
DOC_NUM ITEM_NUM
------- --------
1 1
1 2
2 1
2 2
2 3
3 1
3 2
3 3
What do you want to obtain? What did you try?
NB: Please use the CODE button to format tables.
‎2020 Nov 05 7:00 PM
As per my understanding of your question, you just have one column-"Line Number" in your table which identifies when a new document is started by having value 1.
So, you can put a check on this column and use condition-
IF itab-line_No EQ '1'.
...
ENDIF.AT END OF won't work here as it will trigger at each record when line_no value will change which is each record of your loop.
‎2020 Nov 06 2:25 PM
I suppose your records look like <header_number> <header_field1> ... <header_fieldn> <item_number> <irem_field1> <item_field2> ... and your internal table is already sorted by <header_number> <item_number>
I suggest something like
LOOP AT itab.
" New header
AT NEW <header_number>.
new_header = 'X'.
ENDAT
" Process records (every field available)
IF new_header = 'X'.
move-corresponding record to header_structure.
ELSE.
IF some header field <> saver header field
" raise an error
ENDIF.
ENDIF.
ENDLOOP.
If you don't have a header number, then check <item_number> = 1 instead of setting new_header flag. (And check that <item_number> is always 1 or previous value + 1)