4 weeks ago - last edited 4 weeks ago
I get the ATC error "Do not modify table rows in tables with control level processing" because of the line 18. I'm changing the field SMOKER for further processing after ENDLOOP:
TYPES:
BEGIN OF ty_itab_line,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
smoker TYPE sbook-smoker,
END OF ty_itab_line.
TYPES tt_itab TYPE STANDARD TABLE OF ty_itab_line WITH EMPTY KEY.
DATA(itab) = VALUE tt_itab( carrid = 'LH'
connid = '0370'
fldate = sy-datum
( bookid = 1 smoker = abap_true )
( bookid = 2 smoker = abap_false ) ).
DATA(log) = VALUE string_table( ).
SORT itab BY carrid connid fldate.
LOOP AT itab ASSIGNING FIELD-SYMBOL(<line>).
AT NEW connid.
INSERT |Flight { <line>-carrid }{ <line>-connid } { <line>-fldate }| INTO TABLE log.
DATA(number_of_bookings) = 0.
ENDAT.
<line>-smoker = abap_false.
INSERT | - Booking { <line>-bookid }| INTO TABLE log.
number_of_bookings = number_of_bookings + 1.
AT END OF carrid.
INSERT | - Number of bookings for flight { <line>-carrid }{ <line>-connid
} { <line>-fldate }: { number_of_bookings }| INTO TABLE log.
ENDAT.
ENDLOOP.Sandra_Rossi_0-1761067604343.png
There is no pseudo-comment and no pragma. The only solution is to request an exemption.
How to get rid of this message?
Thanks.
Sandra
4 weeks ago - last edited 4 weeks ago
For this situation, the SAP extended check is simplistic, it can't know if it's a problem or not. As far as I know, it could be a problem only if the field changed is either CARRID and CONNID because the control level logic might be disturbed, but I don't see any problem with the other fields.
The main problem is the absence of pseudo-comment (or pragma) to let the developer confirm that there's no issue.
The workaround is to use LOOP AT GROUP BY instead of the AT control level statements (since ABAP 7.40):
TYPES:
BEGIN OF ty_itab_line,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
smoker TYPE sbook-smoker,
END OF ty_itab_line.
TYPES tt_itab TYPE STANDARD TABLE OF ty_itab_line WITH EMPTY KEY.
DATA(itab) = VALUE tt_itab( carrid = 'LH'
connid = '0370'
fldate = sy-datum
( bookid = 1 smoker = abap_true )
( bookid = 2 smoker = abap_false ) ).
DATA(log) = VALUE string_table( ).
SORT itab BY carrid connid fldate.
LOOP AT itab
ASSIGNING FIELD-SYMBOL(<line>)
GROUP BY ( carrid = <line>-carrid
connid = <line>-connid
fldate = <line>-fldate )
ASSIGNING FIELD-SYMBOL(<group_key>).
INSERT |Flight { <group_key>-carrid }{ <group_key>-connid } { <group_key>-fldate }| INTO TABLE log.
DATA(number_of_bookings) = 0.
LOOP AT GROUP <group_key> ASSIGNING <line>.
<line>-smoker = abap_false.
INSERT | - Booking { <line>-bookid }| INTO TABLE log.
number_of_bookings = number_of_bookings + 1.
ENDLOOP.
INSERT | - Number of bookings for flight { <group_key>-carrid }{ <group_key>-connid
} { <group_key>-fldate }: { number_of_bookings }| INTO TABLE log.
ENDLOOP.
4 weeks ago - last edited 4 weeks ago
For this situation, the SAP extended check is simplistic, it can't know if it's a problem or not. As far as I know, it could be a problem only if the field changed is either CARRID and CONNID because the control level logic might be disturbed, but I don't see any problem with the other fields.
The main problem is the absence of pseudo-comment (or pragma) to let the developer confirm that there's no issue.
The workaround is to use LOOP AT GROUP BY instead of the AT control level statements (since ABAP 7.40):
TYPES:
BEGIN OF ty_itab_line,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
smoker TYPE sbook-smoker,
END OF ty_itab_line.
TYPES tt_itab TYPE STANDARD TABLE OF ty_itab_line WITH EMPTY KEY.
DATA(itab) = VALUE tt_itab( carrid = 'LH'
connid = '0370'
fldate = sy-datum
( bookid = 1 smoker = abap_true )
( bookid = 2 smoker = abap_false ) ).
DATA(log) = VALUE string_table( ).
SORT itab BY carrid connid fldate.
LOOP AT itab
ASSIGNING FIELD-SYMBOL(<line>)
GROUP BY ( carrid = <line>-carrid
connid = <line>-connid
fldate = <line>-fldate )
ASSIGNING FIELD-SYMBOL(<group_key>).
INSERT |Flight { <group_key>-carrid }{ <group_key>-connid } { <group_key>-fldate }| INTO TABLE log.
DATA(number_of_bookings) = 0.
LOOP AT GROUP <group_key> ASSIGNING <line>.
<line>-smoker = abap_false.
INSERT | - Booking { <line>-bookid }| INTO TABLE log.
number_of_bookings = number_of_bookings + 1.
ENDLOOP.
INSERT | - Number of bookings for flight { <group_key>-carrid }{ <group_key>-connid
} { <group_key>-fldate }: { number_of_bookings }| INTO TABLE log.
ENDLOOP.