Application Development and Automation 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: 
Read only

Control level statement query

Former Member
0 Likes
1,009

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.

1 ACCEPTED SOLUTION
Read only

Pankaj_Gupta
Product and Topic Expert
Product and Topic Expert
0 Likes
932

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.

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
0 Likes
932

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.

Read only

Pankaj_Gupta
Product and Topic Expert
Product and Topic Expert
0 Likes
933

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
932

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)