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

Report

Former Member
0 Likes
901

Hi,

i am fetching the data from LFA1. Fields are LIFNR, NAME1, NAME2.

Now i need to add name1 and name2 .

i want displayboth fields in one field in output.

please give me solution as early as possible

1 ACCEPTED SOLUTION
Read only

former_member188829
Active Contributor
0 Likes
843

Hi,

TABLES:LFA1.

SELECT-OPTIONS:S_LIFNR FOR LFA1-LIFNR.

DATA:BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

NAME2 LIKE LFA1-NAME2,

END OF ITAB.

DATA:NAME_FINAL(50) TYPE C.

START-OF-SELECTION.

SELECT LIFNR

NAME1

NAME2 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

LOOP AT ITAB.

CONCATENATE ITAB-NAME1 ITAB-NAME2 INTO NAME_FINAL.

WRITE:/ ITAB-LIFNR,ITAB-NAME1,ITAB-NAME2,NAME_FINAL.

ENDLOOP.

6 REPLIES 6
Read only

Former Member
0 Likes
843

in ALV or classic????

Read only

former_member188829
Active Contributor
0 Likes
844

Hi,

TABLES:LFA1.

SELECT-OPTIONS:S_LIFNR FOR LFA1-LIFNR.

DATA:BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

NAME2 LIKE LFA1-NAME2,

END OF ITAB.

DATA:NAME_FINAL(50) TYPE C.

START-OF-SELECTION.

SELECT LIFNR

NAME1

NAME2 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

LOOP AT ITAB.

CONCATENATE ITAB-NAME1 ITAB-NAME2 INTO NAME_FINAL.

WRITE:/ ITAB-LIFNR,ITAB-NAME1,ITAB-NAME2,NAME_FINAL.

ENDLOOP.

Read only

Former Member
0 Likes
843

Hi,

Do as below :

data : begin of itab occurs 0,

lifnr like lfa1-lifnr,

name1 like lfa1-name1,

name2 like lfa1-name2,

fullname(40) type c,

end of itab.

write select statement toget the data into itab.

loop at itab.

concatenate name1 name2 into fullname.

modify itab.

clear itab.

endloop.

now write to the output list.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
843

Hi Santosh,

This is very simple if it is in the classic report. Concatenate the two fields which you fetched from the table into one field and then display it. But make sure that field length of the full_name is sum of lengths of both the fields name1 and name2 so that you wont loose any information.

concatenate tab-name1 tab-name2 into full_name.

write : / full_name.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Jan 11, 2008 6:17 PM

Read only

Former Member
0 Likes
843

DATA : BEGIN OF itab OCCURS 0,
      lifnr LIKE lfa1-lifnr,
      name1 LIKE lfa1-name1,
      name2 LIKE lfa1-name2,
      full_name(72),
      END OF itab.

START-OF-SELECTION.

  SELECT lifnr name1 name2 INTO CORRESPONDING FIELDS OF TABLE itab FROM lfa1.

  LOOP AT itab.
    CONCATENATE itab-name1 itab-name2 INTO itab-full_name SEPARATED BY space.
    MODIFY itab INDEX sy-tabix.
  ENDLOOP.

"in case ALV pass this table to REUSE_ALV .and in  fieldcat do not add name1 name2.
"if calssic report

LOOP AT itab.
WRITE :/ itab-lifnar, itab-full_name.
ENDLOOP.
Read only

Former Member
0 Likes
843

Hi,

concatenate will surely help you regarding this.

just retreive the names and concatenate the two names,

then move this into another string and finally in the

write statement include the above string

please do an F1 on concatenate,this may probably help you.

LOOP AT itab.

CONCATENATE <name1>< name2> INTO full_name SEPARATED BY space.

MODIFY itab INDEX sy-tabix.

ENDLOOP.

<REMOVED BY MODERATOR>

thanks and regards,

srikanth tulasi.

Edited by: Alvaro Tejada Galindo on Jan 11, 2008 6:17 PM