Application Development 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: 

write in loop

jayant_kumar
Explorer
0 Kudos
144

Hi,

plz tell me where i do mistake in a loop stmt. i am not write the output its write only single record but there is three records in this internal table its display only last record.

if p_back = 'X'.

loop at ch_it_output into ch_wa_output.

write: ch_wa_output-werks UNDER 'Plant',

ch_wa_output-pkunag UNDER 'TP Code',

ch_wa_output-name1 UNDER 'TP Name',

ch_wa_output-zzamatkl UNDER 'Country Material Grp.',

ch_wa_output-kam1 UNDER 'Kam',

ch_wa_output-salqty1 UNDER 'Sales-YTD QTY Previous Year',

ch_wa_output-salval1 UNDER 'Sales-YTD Value Previous Year',

ch_wa_output-prv_provi UNDER 'KAM CY Provision YTD Previous Year',

ch_wa_output-prv_acpayout UNDER 'Actual Payout Previous Year',

ch_wa_output-salqty2 UNDER 'Sales-YTD QTY Current Year',

ch_wa_output-salval2 under 'Sales-YTD Value Current Year',

ch_wa_output-tsalesqty UNDER 'Target Sales QTY',

ch_wa_output-tsalesval UNDER 'Target Sales Value',

ch_wa_output-kamestval under 'KAM Estimate Value',

ch_wa_output-kamcyper UNDER 'KAM CY-%',

ch_wa_output-provi UNDER 'KAM CY Provision YTD Current Year',

ch_wa_output-acpayout UNDER 'Actual Payout Current Year',

ch_wa_output-balance UNDER 'Bal. YTD Previous',

ch_wa_output-sales UNDER 'Sales QTY',

ch_wa_output-value UNDER 'Value',

ch_wa_output-kam UNDER 'KAM'.

endloop.

endif.

Thanks

jayant.

it write only single record.

8 REPLIES 8

Former Member
0 Kudos
77

Hi,

Try clearing the work area ch_wa_output before Endloop.

********************

..................

.........

Clear: ch_wa_output

ENDLOOP.

ENDIF.

*****************

Hope it works

Regards,

Syed

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos
77

Hi ,

Code looks fine.

may be you can try WRITE 😕 ....

Rgds,

Sandeep

Former Member
0 Kudos
77

Hi,

modify it like:

if p_back = 'X'.

loop at ch_it_output into ch_wa_output.

SKIP.

write: ch_wa_output-werks UNDER 'Plant',

ch_wa_output-pkunag UNDER 'TP Code',

ch_wa_output-name1 UNDER 'TP Name',

ch_wa_output-zzamatkl UNDER 'Country Material Grp.',

ch_wa_output-kam1 UNDER 'Kam',

ch_wa_output-salqty1 UNDER 'Sales-YTD QTY Previous Year',

ch_wa_output-salval1 UNDER 'Sales-YTD Value Previous Year',

ch_wa_output-prv_provi UNDER 'KAM CY Provision YTD Previous Year',

ch_wa_output-prv_acpayout UNDER 'Actual Payout Previous Year',

ch_wa_output-salqty2 UNDER 'Sales-YTD QTY Current Year',

ch_wa_output-salval2 under 'Sales-YTD Value Current Year',

ch_wa_output-tsalesqty UNDER 'Target Sales QTY',

ch_wa_output-tsalesval UNDER 'Target Sales Value',

ch_wa_output-kamestval under 'KAM Estimate Value',

ch_wa_output-kamcyper UNDER 'KAM CY-%',

ch_wa_output-provi UNDER 'KAM CY Provision YTD Current Year',

ch_wa_output-acpayout UNDER 'Actual Payout Current Year',

ch_wa_output-balance UNDER 'Bal. YTD Previous',

ch_wa_output-sales UNDER 'Sales QTY',

ch_wa_output-value UNDER 'Value',

ch_wa_output-kam UNDER 'KAM'.

endloop.

endif.

Regards,

Renjith Michael.

Former Member
0 Kudos
77

Hi,

if p_back = 'X'.

loop at ch_it_output into ch_wa_output.

write: / ch_wa_output-werks UNDER 'Plant',

ch_wa_output-pkunag UNDER 'TP Code',

ch_wa_output-name1 UNDER 'TP Name',

ch_wa_output-zzamatkl UNDER 'Country Material Grp.',

ch_wa_output-kam1 UNDER 'Kam',

ch_wa_output-salqty1 UNDER 'Sales-YTD QTY Previous Year',

ch_wa_output-salval1 UNDER 'Sales-YTD Value Previous Year',

ch_wa_output-prv_provi UNDER 'KAM CY Provision YTD Previous Year',

ch_wa_output-prv_acpayout UNDER 'Actual Payout Previous Year',

ch_wa_output-salqty2 UNDER 'Sales-YTD QTY Current Year',

ch_wa_output-salval2 under 'Sales-YTD Value Current Year',

ch_wa_output-tsalesqty UNDER 'Target Sales QTY',

ch_wa_output-tsalesval UNDER 'Target Sales Value',

ch_wa_output-kamestval under 'KAM Estimate Value',

ch_wa_output-kamcyper UNDER 'KAM CY-%',

ch_wa_output-provi UNDER 'KAM CY Provision YTD Current Year',

ch_wa_output-acpayout UNDER 'Actual Payout Current Year',

ch_wa_output-balance UNDER 'Bal. YTD Previous',

ch_wa_output-sales UNDER 'Sales QTY',

ch_wa_output-value UNDER 'Value',

ch_wa_output-kam UNDER 'KAM'.

clear ch_wa_output.

endloop.

endif.

0 Kudos
77

plz tell me how can i execute this code output in background means in SE37.

plz specify the code for it.

thanks,

jayant

0 Kudos
77

U can create the background job in sm36 and u can execute it from sm37.

i048168
Advisor
Advisor
0 Kudos
77

Hi,

I think there is no problem in the code segment that you have shown here.

May be it could have been printed somewhere else. Please check it out.

Regards,

Vadivelan B

Former Member
0 Kudos
77

your code looks good. i checked your code and write statement is writing records side by side. check your data type declaration. use write:/ to print one by one.

Regards

Raghu