2009 Feb 09 5:37 AM
Hi,
1. Which system fields are affected when i use the key word AT FIRST/ AT LAST / AT NEW / AT END ?? [Similar to sy-subrc is affected after a select query]
2. I am trying to print a variable (work area field) in AT statement. The WRITE statement prints ***** instead of the content in the work area fields . Why is it so??
LOOP at it_customers into wa_customers.
AT FIRST.
Write:/ 'Inside First Block'.
Write:/ wa_customers-ID , wa-customers-name.
ENDAT.
ENDLOOP.
-Raj
2009 Feb 09 5:44 AM
hi...
in type declearation...
put the field which you want to display before the field you specify in at first <field>
at first or at last donot effect system field
2. if you are specifying a field name in at first and you are trying to write any other field of type c and which come after the field in at first.....then inside at first and endat it will give ***** and for filed of type numeric it will give zeros..
whst you can do is to change the order in which the field exist in type definition
regards
Edited by: Mohit Kumar on Feb 9, 2009 6:45 AM
hi...
in type declearation...
put the field which you want to display before the field you specify in at first <field>
at first or at last donot effect system field
2. if you are specifying a field name in at first and you are trying to write any other field of type c and which come after the field in at first.....then inside at first and endat it will give ***** and for filed of type numeric it will give zeros..
whst you can do is to change the order in which the field exist in type definition
regards
Edited by: Mohit Kumar on Feb 9, 2009 6:45 AM
2009 Feb 09 5:40 AM
HI,
Try this way...
Wheb you use the AT FIRST/LAST events the fields after the fields you specifed in the AT FIRST/LAST Event will have the stars in it.
If you don't specify fields in the AT FIRST/LAST event then all the fields in the header line have the stars in it.
To overcome this move the values to the variable as show in the below example...
DATA : g_customers like wa_customers.
LOOP at it_customers into wa_customers.
MOVE wa_customers TO g_customers.
AT FIRST.
Write:/ 'Inside First Block'.
Write:/ g_customers-ID , g_customers-name.
ENDAT.
ENDLOOP.Edited by: Avinash Kodarapu on Feb 9, 2009 11:10 AM
2009 Feb 09 6:00 AM
>
> Wheb you use the AT FIRST/LAST events the fields after the fields you specifed in the AT FIRST/LAST Event will have the stars in it.
Hello Avinash,
You do not use any fields after AT FIRST/LAST stmts )
BR,
Suhas
2009 Feb 09 5:41 AM
Hi.
in at new and at change of the wa_itab will not save the contents of the fields of it's right side.
so it is better to use an other work area. and before at new or at change make like this.
wa_itab2 = wa_itab1
append wa_itab2 to itab2.
then perform the functionality of at new or else.
2009 Feb 09 5:44 AM
1. sy-subrc will work not only for select but for all statements.
2. If you are using control break statement at new will not show record values on right side.
For that you have to define another internal table and move the data to it and display.
2009 Feb 09 5:44 AM
Hi,
In Control Statements (AT) if there are any character field at the right after the field in AT it will appear as *** and Integer as ' '.
If you want to print these value capture the value of sy-tabix in the At and print the value outside ENDAT.
This will resolve teh issue..
Note: Internal Table should be always sorted.
Regards,
Gurpreet
2009 Feb 09 5:44 AM
Hi,
Before u loop, u have to sort the internala table ..dis is a prerequisite to use AT statements.
In u ITAB structure,which field u r trying to use in AT statement...y becoz..it takes all of the fields before to that are take it as keyfields..thats y u r getting ****.
Dats y it is printing the left values and right values as *****.Check u t internal table structure..
Regards
Kiran
Edited by: Kiran Saka on Feb 9, 2009 6:44 AM
Edited by: Kiran Saka on Feb 9, 2009 6:45 AM
2009 Feb 09 5:44 AM
Hi Raj,
In AT First and AT last statement you will not get the values of the work area completely they will have only initial values for all numeric fields and * for character fields....
In AT new <field_name> and AT end of <field_name> will take the values of all the left fields of the field_name and all the fields which are at right of the field_name will take the initial values....
so to get the values of these fields in the at events.... please use the code mentioned below,
I am taking a new wa which is similar to the wa you have used and assigning its value in the loop and then use at events....
data wa_customers1 like wa_customers.
LOOP at it_customers into wa_customers.
wa_customers1 = wa_customers.
AT FIRST.
Write:/ 'Inside First Block'.
Write:/ wa_customers1-ID , wa-customers1-name.
ENDAT.
ENDLOOP.
this works,
Regards,
Siddarth
2009 Feb 09 5:44 AM
hi...
in type declearation...
put the field which you want to display before the field you specify in at first <field>
at first or at last donot effect system field
2. if you are specifying a field name in at first and you are trying to write any other field of type c and which come after the field in at first.....then inside at first and endat it will give ***** and for filed of type numeric it will give zeros..
whst you can do is to change the order in which the field exist in type definition
regards
Edited by: Mohit Kumar on Feb 9, 2009 6:45 AM
2009 Feb 09 5:52 AM
Hi Raj ,
This ***** are not because of system fields problem with Control break statements.
If your table having 5 fileds and you are doing AT New of FLD3 ( Third field ) then fld4 and fld 5 will be coming like ***** ( Stars ) or spaces ( ' ' ) according to their data types .
To avoid that you can either write any function like SUM in the at new block or write the fields which are right sided fields of specified field in the At New ( In my example FLD4 & fld 5 ) out of the loop .
1)
loop at .........
at new fld 3 .
write : / fld1, fld2 , fld.
endat.
write fld4 , fld5 .
endloop.
Or 2)
loop at .........
at new fld 3 .
sum.
..............................
Regards
Pinaki
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |