2008 Feb 19 4:07 AM
hi fellow abapers,
please go through the follwing code and please help me in telling exact logical mistake in my code ??
*CODE: *
Loop at IT_FINAL_INFO INTO WA_FINAL_INFO where EBELN = W_FIELDVAL.
WRITE: /13 WA_FINAL_INFO-EBELN color 1,
30 WA_FINAL_INFO-MATNR color 1,
48 WA_FINAL_INFO-MTART color 1,
70 WA_FINAL_INFO-MENGE UNIT c_unit_field color 1,
88 WA_FINAL_INFO-MEINS color 1,
95 WA_FINAL_INFO-PEINH color 1,
105 WA_FINAL_INFO-NETPR CURRENCY C_USD color 1,
124 WA_FINAL_INFO-NETWR CURRENCY C_USD color 1.
AT END OF EBELN.
ULINE.
SUM.
WRITE: /107 TEXT-015 color 6,
124 WA_FINAL_INFO-NETWR CURRENCY C_USD color 6.
ENDAT.
ENDLOOP.
IN EPC >>> warning is coming as "Problematic Satement"
SYNTAX WARNING
The LOOP statement processing will be limited
(FROM, TO and WHERE additions in LOOP)
Interaction with group change processing (AT NEW, ...) is undefined
---> AT END OF EBELN.
SUM.
ENDAT.
is working fine and giving the desired output, then what is the reason behind this Syntax warning,
and please give effecient and optimized way to rmeove this ???
thanks in advance
Rohan malik
2008 Feb 19 4:08 AM
hi
hope it will give u some idea.
Reward if help.
AT - Control break with internal tables
Variants
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
Effect
In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
All default key fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key.
Between AT and ENDAT , you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types ) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level ( AT FIRST , AT NEW f ) and also the end of a control level ( AT END OF f , AT LAST ).
At the end of the control level processing (i.e. after ENDAT ), the old contents of the LOOP output area are restored.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOP s on extracts, there are also special control break control structures you can use.
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
SELECT *
FROM sflight
INTO TABLE sflight_tab.
LOOP AT sflight_tab INTO sflight_wa.
AT NEW connid.
WRITE: / sflight_wa-carrid,
sflight_wa-connid.
ULINE.
ENDAT.
WRITE: / sflight_wa-fldate,
sflight_wa-seatsocc.
AT END OF connid.
SUM.
ULINE.
WRITE: / 'Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
SKIP.
ENDAT.
AT END OF carrid.
SUM.
ULINE.
WRITE: / 'Carrier Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
WRITE: / 'Overall Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
ENDAT.
ENDLOOP.
2008 Feb 19 4:08 AM
hi
hope it will give u some idea.
Reward if help.
AT - Control break with internal tables
Variants
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
Effect
In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
All default key fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key.
Between AT and ENDAT , you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types ) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level ( AT FIRST , AT NEW f ) and also the end of a control level ( AT END OF f , AT LAST ).
At the end of the control level processing (i.e. after ENDAT ), the old contents of the LOOP output area are restored.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOP s on extracts, there are also special control break control structures you can use.
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
SELECT *
FROM sflight
INTO TABLE sflight_tab.
LOOP AT sflight_tab INTO sflight_wa.
AT NEW connid.
WRITE: / sflight_wa-carrid,
sflight_wa-connid.
ULINE.
ENDAT.
WRITE: / sflight_wa-fldate,
sflight_wa-seatsocc.
AT END OF connid.
SUM.
ULINE.
WRITE: / 'Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
SKIP.
ENDAT.
AT END OF carrid.
SUM.
ULINE.
WRITE: / 'Carrier Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
WRITE: / 'Overall Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
ENDAT.
ENDLOOP.
2008 Feb 19 4:13 AM
Hi,
U need to remove the where condition in the loop.
Loop at IT_FINAL_INFO INTO WA_FINAL_INFO .
IF WA_FINAL_INFO-EBELN = W_FIELDVAL.
WRITE: /13 WA_FINAL_INFO-EBELN color 1,
30 WA_FINAL_INFO-MATNR color 1,
48 WA_FINAL_INFO-MTART color 1,
70 WA_FINAL_INFO-MENGE UNIT
c_unit_field color 1,
88 WA_FINAL_INFO-MEINS color 1,
95 WA_FINAL_INFO-PEINH color 1,
105 WA_FINAL_INFO-NETPR
CURRENCY C_USD color 1,
124 WA_FINAL_INFO-NETWR CURRENCY
C_USD color 1.
AT END OF EBELN.
ULINE.
SUM.
WRITE: /107 TEXT-015 color 6,
124 WA_FINAL_INFO-NETWR CURRENCY C_USD color 6.
ENDAT.
ENDIF.
ENDLOOP..
Hope this helps, revert back if incase any queries.
2008 Feb 19 4:22 AM
hi judith,
thanks for the reply,
but i still didn;t got to the bottom of the problem..
>>> This is the documentaiton !!
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
but why is it giving warning and if so.. how come my output is coming as desired.. ??
and moreover...with using IF condition, output is not coming as desired !!
thanks in advance
Rohan
2008 Feb 19 4:36 AM
Hi,
It is a warning message, this wont affect your output at any cause.
But it is just giving you a warning like:
When you use AT condtions you should not give any restrictions for the LOOP statement....
Remove the IF condition also if needed do the check before writing the output.
The IF can be there after the AT...
Example:
LOOP AT...
IF .....
Write...
ENDIF.
AT END ...
IF....
WRITE....
ENDIF..
ENDAT....
ENDLOOP.
I have used the IF as a whole so it might not ahve worked.
2008 Feb 19 4:44 AM
sort IT_FINAL_INFO by ebeln.
Loop at IT_FINAL_INFO INTO WA_FINAL_INFO .
if WA_FINAL_INFO-EBELN = W_FIELDVAL.
WRITE: /13 WA_FINAL_INFO-EBELN color 1,
30 WA_FINAL_INFO-MATNR color 1,
48 WA_FINAL_INFO-MTART color 1,
70 WA_FINAL_INFO-MENGE UNIT c_unit_field color 1,
88 WA_FINAL_INFO-MEINS color 1,
95 WA_FINAL_INFO-PEINH color 1,
105 WA_FINAL_INFO-NETPR CURRENCY C_USD color 1,
124 WA_FINAL_INFO-NETWR CURRENCY C_USD color 1.
AT END OF EBELN.
ULINE.
SUM.
WRITE: /107 TEXT-015 color 6,
124 WA_FINAL_INFO-NETWR CURRENCY C_USD color 6.
ENDAT.
ENDIF.
ENDLOOP.
Hi actually it wont create a problem...But its a warning....
No logical conditions are allowed when u use control break statements.....
U can hide this warning using "EC check as showed in the warning..
Or try my above code....
2008 Feb 19 4:56 AM