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

Former Member
0 Likes
1,257

HI EXPERTS,

my write statement is

WRITE:/ 'users',

userid-low.

Now the output is like user id vs1234 ,aj34526 .

but i need the output like user id vs1234,aj34526.

length of user id is 12 chars....

can someone shed some light on this issue....

Thanks in advanse...

SRI

1 ACCEPTED SOLUTION
Read only

rahulkavuri
Active Contributor
0 Likes
1,226

hi declare 3 variables char1(12), char2(12),char3(24).

where char3 holds the final output

data: char1(12), char(12), char3(24).

char1 = userid.

char2 = userid-low.

concatenate char1 char2 into char3.

condense char3 no-gaps.

write:/ char3.

<b>award points if found helpful</b>

16 REPLIES 16
Read only

rahulkavuri
Active Contributor
0 Likes
1,227

hi declare 3 variables char1(12), char2(12),char3(24).

where char3 holds the final output

data: char1(12), char(12), char3(24).

char1 = userid.

char2 = userid-low.

concatenate char1 char2 into char3.

condense char3 no-gaps.

write:/ char3.

<b>award points if found helpful</b>

Read only

0 Likes
1,226

Hi Rahul,

Thanks alot for your reply

here i mentioned only two user id's, actually i wll get more than 10 userid's in a single line and lenght of the user id may change from one user to other user

how to handle this..?

Read only

0 Likes
1,226

You man have to store all such userids in an internal table with two fields.

1. user id

2. final result

1. loop at internal table

2. concatenate

3. store in final result

4. modify table

Hope this helps..

Thanks,

Santosh

Read only

0 Likes
1,226

hi can u post the part of code, i can definitely help in that regard

as far as i understand if u are going to get all the user-id's in a single line then simply use condense statement which remove all the extra spaces..

Read only

0 Likes
1,226

Hi,

Use:

Write:/5 (user_id1), 20 (user_id2), 35 (user_id3).

This will print all the user ids at the specific columns.

Regards

Subramanian

Read only

Former Member
0 Likes
1,226

If you have many userid's..

loop at internal table with the userid's

Declare a variable which is of maximum length of all the userid's.

v_variable.

concatenate userid ',' v_variable to v_variable.

condense v_variable with no-gaps.

endloop.

write : v_variable.

Srini.

Read only

Former Member
0 Likes
1,226

I will check it out and will be back....

Read only

Clemenss
Active Contributor
0 Likes
1,226

Hi,

write will add a trailing space character after every output field. If you do not want this, use the option NO-GAP.

Your example will not output the comma caus e the closing ' is missing - where did that go?

Try


WRITE:/ user id NO-GAP,  ',', userid-low.

Regards,

Clemens

Read only

Former Member
0 Likes
1,226

Sorry guys I am having only one varibale ie userid-low

I corrected my question... can some one help me now...

Read only

0 Likes
1,226

ok

char1 = userid-low.

condense char1 no-gaps.

write:/ char1.

This will work, dont forget to award points

Read only

0 Likes
1,226

in that case just say:

CONDENSE userid-low NO-GAPS.

WRITE:/ userid-low.

Thanks,

Santosh

Read only

0 Likes
1,226

I am getting the same result again even though i applied the above logic

can u check it out one more time plzzzzz

Read only

0 Likes
1,226

Hi

If you want to delete the spaces on the left, you should check the how many characters are filled and print only them:

DATA: USER  LIKE SY-UNAME VALUE 'id12345',
      USER2 LIKE SY-UNAME VALUE 'aaaaa',
      USER3 LIKE SY-UNAME VALUE 'bbb',
      USER4 LIKE SY-UNAME VALUE 'idaacccc'.

WRITE: 'Users:'.

PERFORM WRITE_USER USING:  USER  ',',
                           USER2 ',',
                           USER3 ',',
                           USER4 '.'.
*&---------------------------------------------------------------------*
*&      Form  WRITE_USER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_USER  text
*----------------------------------------------------------------------*
FORM WRITE_USER USING    P_USER P_SYMB.
  DATA: LEN TYPE I.

  LEN = STRLEN( P_USER ).

  WRITE: P_USER(LEN) NO-GAP, P_SYMB NO-GAP.
ENDFORM.                    " WRITE_USER

Max

Read only

Clemenss
Active Contributor
0 Likes
1,226

Sri,

try in system: WRITE will never output a comma if there is none enclosed in HYPHENS like ','.

If you don't want the trailing space, use addition NO-GAP. If you want the output restricted t the actual length of the username you can specify an output length:


data:
  lv_len type sytleng.

lv_len = strlen( userid-low ).

Write: / (lv_len) userid-low, 'is the user's name'. 

Another option might be to put the cursor on the WRITE and press F1 - and take some time

Regards,

Clemens

Read only

Former Member
0 Likes
1,226

Hi,

My problem partially solved...

Now I want to print this result in alv footer how to do it......

Can anyone plz help me regarding this?

Read only

Former Member
0 Likes
1,226

Hi

U've to use the END_OF_PAGE event.

I don't know which kind of ALV you're using, but the way it's always the same.

ALV functions have the parameter where the events are transfered, here u insert the name of the event and the name of the form has to be run in the event:

LS_EVENT-NAME = 'END_OF_PAGE'. "<----- Event name
LS_EVENT-FORM = 'END_OF_PAGE'. "<----- Form name
APPEND LS_EVENT TO GT_EVENTS.

GT_REPID = SY-REPID. "<----- The report where routine is defined

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            i_callback_program       = gt_repid
            it_events                      = gt_events
.......................................................................


* Form

FORM END_OF_PAGE.
* Here write your code of the footer
ENDFORM.

U can use the event END_OF_LIST insted of END_OF_PAGE

In the OO ALV you should find the same events

Max