2013 Nov 19 12:21 PM
Hello Friends,
I have a WRITE Statement in my Program which writes Values under HEADERS. But even after giving the correct Length this WRITE SATATEMENT is not WRITING THE Values Properly. Please Have a LOOK.
CODE
WRITE:/0 'Sales Order',15 'Order Qty',29 '3rd Party Ref',43 'Sold-To-Party',57 'Name',87 'Partner Reference',105 'Route'.
SKIP.
LOOP AT it_final_sales INTO wa_final_sales.
WRITE:/0 wa_final_sales-vbeln,15 wa_final_sales-kwmeng,29 wa_final_sales-bstnk,43 wa_final_sales-kunnr,57 wa_final_sales-name1,87 wa_final_sales-knref,
105 wa_final_sales-route.
ENDLOOP.
SKIP.
FORMAT INTENSIFIED ON.
WRITE:/'Total Sales Orders:',v_tot_sales,32 'Total Qty:',v_tot_sales_qty.
FORMAT INTENSIFIED OFF.
Please Check the DISPLAY Format in the IMAGE which I am attaching.
Here the 2nd column, wa_final_sales-kwmeng is merging with 3rd column wa_final_sales-bstnk. And Sales Order Numbers are also not showing up properly, i.e they are showing up without zeros. and KWMENG is coming without zeroes.
When I dubugged I found that Internal Table is getting proper values but in DISPLAY values are not coming in correct order.
PLEASE HELP ME WITH THIS.
2013 Nov 19 12:37 PM
HI anirban,
Try increasing the starting point of second header from 15 to 20 . then you can view the output clearly.
Like wise change the length of all the fields to make it visible clearly.
2013 Nov 19 12:45 PM
Hi Anirban,
Write without leading zeros is normal. As for positions you must justify, play a little until is all ok.
For example, look this document: http://scn.sap.com/docs/DOC-48511
Regards,
Vladimir
2013 Nov 19 12:57 PM
Hi Anirban,
I think its due to quantity field being written in format of Right-Justification by default.
You can try this :
DATA : l_kwmeng(14) TYPE C.
LOOP AT it_final_sales INTO wa_final_sales.
l_kwmeng = wa_final_sales-kwmeng.
WRITE:/0 wa_final_sales-vbeln,15 l_kwmeng CENTRE-JUSTIFIED,29 wa_final_sales-bstnk,43 wa_final_sales-kunnr,57 wa_final_sales-name1,87 wa_final_sales-knref,
105 wa_final_sales-route.
ENDLOOP.
Thanks & Regards,
Chirdip
2013 Nov 19 1:02 PM
Dearn anirban,
use this format it will solve your problem.
and in future you can easily add coloumns as well.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN TYPE LIPS-VBELN,
KWMENG TYPE VBAP-KWMENG,
BSTNK TYPE BSTNK,
KUNNR TYPE LIKP-KUNNR,
END OF ITAB.
DATA: COL TYPE I.
ITAB-VBELN = '0000006704'.
ITAB-KWMENG = '1.000'.
ITAB-BSTNK = ''.
ITAB-KUNNR = '0010155659'.
APPEND ITAB.
CLEAR: ITAB.
ITAB-VBELN = '0000006704'.
ITAB-KWMENG = '2.000'.
ITAB-BSTNK = ''.
ITAB-KUNNR = '0010155659'.
APPEND ITAB.
CLEAR: ITAB.
ITAB-VBELN = '0000006704'.
ITAB-KWMENG = '1.000'.
ITAB-BSTNK = ''.
ITAB-KUNNR = '0010155659'.
APPEND ITAB.
CLEAR: ITAB.
ITAB-VBELN = '0000006704'.
ITAB-KWMENG = '1.000'.
ITAB-BSTNK = '302883'.
ITAB-KUNNR = '0010155659'.
APPEND ITAB.
CLEAR: ITAB.
LOOP AT ITAB.
at FIRST.
write: at 1(63) sy-uline.
write: at /col(2) sy-vline.
col = col + 2.
FORMAT INTENSIFIED COLOR = 6.
write: at col(10) 'Sales Order' intensified on.
col = col + 10.
write: at col(1) sy-vline.
col = col + 1.
FORMAT INTENSIFIED COLOR = 7.
write: at col(15) 'Order Qty' intensified on.
col = col + 15.
write: at col(1) sy-vline.
col = col + 1.
FORMAT INTENSIFIED COLOR = 7.
write: at col(15) '3rd Party Ref' intensified on.
col = col + 15.
write: at col(1) sy-vline.
col = col + 1.
FORMAT INTENSIFIED COLOR = 7.
write: at col(15) 'Sold-To-Party' intensified on.
col = col + 15.
write: at 63(1) sy-vline.
col = col + 1.
write: at /1(63) sy-uline.
FORMAT INTENSIFIED OFF.
CLEAR: COL.
COL = 0.
ENDAT.
write: at 1(63) sy-uline.
write: at /col(2) sy-vline.
col = col + 2.
write: at col(10) ITAB-VBELN .
col = col + 10.
write: at col(1) sy-vline.
col = col + 1.
write: at col(15) ITAB-KWMENG .
col = col + 15.
write: at col(1) sy-vline.
col = col + 1.
write: at col(15) ITAB-BSTNK .
col = col + 15.
write: at col(1) sy-vline.
col = col + 1.
write: at col(15) ITAB-KUNNR .
col = col + 15.
write: at 63(1) sy-vline.
col = col + 1.
write: at /1(63) sy-uline.
COL = 0.
ENDLOOP.
regards,
2013 Nov 19 1:03 PM
It is because numbers are right justified normally. Give the addition left justified for the integer field to display the output in the right format.
WRITE:/0 wa_final_sales-vbeln,15 wa_final_sales-kwmeng LEFT-JUSTIFIED, 29 wa_final_sales-bstnk,43 wa_final_sales-kunnr,57 wa_final_sales-name1,87 wa_final_sales-knref,
105 wa_final_sales-route.
2013 Nov 19 8:42 PM
Anirban, I guess Susmitha's and Zahid's options should work. Not to forget Unit reference for the quantity field.
2013 Nov 19 2:02 PM
Hi Anirban,
Do the code like this.
WRITE:/0 'Sales Order',15 'Order Qty',29 '3rd Party Ref',43 'Sold-To-Party',57 'Name',87 'Partner Reference',105 'Route'.
SKIP.
LOOP AT it_final_sales INTO wa_final_sales.
WRITE:/ wa_final_sales-vbeln under 'Sales Order', wa_final_sales-kwmeng under 'Order Qty' centered, wa_final_sales-bstnk under '3rd Party Ref',wa_final_sales-kunnr under 'Sold-To-Party', wa_final_sales-name1 under 'Name', wa_final_sales-knref under 'Partner Reference', wa_final_sales-route under 'Route'.
ENDLOOP.
SKIP.
FORMAT INTENSIFIED ON.
WRITE:/'Total Sales Orders:',v_tot_sales,32 'Total Qty:',v_tot_sales_qty.
FORMAT INTENSIFIED OFF.
Please let me know your output.
Regards
Venkat.
2013 Nov 19 2:06 PM
Hi-
Check below sample code:
TABLES: vbap.
TYPES: BEGIN OF t_vbap,
vbeln TYPE vbap-vbeln,
kwmeng TYPE vbap-kwmeng,
vrkme TYPE vbap-vrkme,
END OF t_vbap.
DATA: it_vbap TYPE STANDARD TABLE OF t_vbap,
wa_vbap TYPE t_vbap.
SELECT vbeln
kwmeng
vrkme
FROM vbap
UP TO 20 ROWS
INTO TABLE it_vbap.
IF it_vbap IS NOT INITIAL.
WRITE: 10 'Sales Order', 30 'Quantity', 50 'Sales Unit'.
LOOP AT it_vbap INTO wa_vbap.
WRITE: / wa_vbap-vbeln UNDER 'Sales Order',
wa_vbap-kwmeng UNDER 'Quantity' LEFT-JUSTIFIED,
wa_vbap-vrkme UNDER 'Sales Unit'.
ENDLOOP.
ENDIF.
Output:
Venkat
2013 Nov 19 3:33 PM
Hi Venkat,
I have one valuable addition to your code.
When writing quantity specify addition "UNIT" and it will write with the decimals from the respective unit. Thus when you have "PC" (pieces) it will not write decimals on the screen.
Regards,
Bruno
2013 Nov 19 8:01 PM
Hi Anirban,
As suggested by Susmitha try in that way,
otherwise take one variable of character type and pass the field value into that variable and print that variable by Writing CONDENSE.
lv_value = kmeng.
condense lv_value.
write: lv_value.
Regards,
Nishant Bansal
2013 Nov 20 5:12 AM
> To display the leading zeros use FM 'Conversion_Exit_Alpha_Output' before the write statement. Pass work area field to it and provide the same field to get the value with leading zeroes back.
> Quantity field display length is 17, and only 14 places are provided for its display. Increase the width of that column.