Application Development and Automation 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: 
Read only

WRITE STATEMENT NOT working properly

Former Member
0 Likes
4,146

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.


11 REPLIES 11
Read only

sivaganesh_krishnan
Contributor
0 Likes
2,641

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.

Read only

vladimir_erakovic
Contributor
0 Likes
2,641

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

Read only

Former Member
0 Likes
2,641

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

Read only

Former Member
0 Likes
2,641

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,

Read only

Former Member
0 Likes
2,641

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.

Read only

0 Likes
2,641

Anirban, I guess Susmitha's and Zahid's options should work. Not to forget Unit reference for the quantity field.

Read only

former_member206479
Participant
0 Likes
2,641

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.

Read only

venkat_aileni
Contributor
0 Likes
2,641

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

Read only

0 Likes
2,641

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

Read only

nishantbansal91
Active Contributor
0 Likes
2,641

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

Read only

Former Member
0 Likes
2,641

> 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.