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: 

Concatenate BSEG fields.

Former Member
0 Kudos

Hi Guys,

I ahve to download data in a text file from SAP.The format must be ' | ' or pipe delimiter. So i am using SAP_to_convert_tex_format.But this is not working for BSEG table. So i am using concatenate for all the fields and seperated by ' | '.while conatenating i am getting syntax error for the result it_bseg1.That declare it_bseg1 as character type .i declared it_bseg1 as

data : it_bseg1(4096) type c occurs 0.

can any body tell me how to solve this one.

i wrote concatenate all fields................into it_bseg1 seperated by '|'.

Thanks,

Gopi.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate

Please try this example program.



report zrich_0001 .

data: ibseg type table of bseg.
data: xbseg like line of ibseg.

data: istr type table of string,
      xstr type string.
data: xtmp type string.
field-symbols: <fs>.


select * into table ibseg from bseg
           up to 100 rows.

loop at ibseg into xbseg.

  do.
    assign component sy-index of structure xbseg to <fs>.
    if sy-subrc <> 0.
      exit.
    endif.
    xtmp = <fs>.
    if sy-index = 1.
      xstr = xtmp.
    else.
      concatenate xstr xtmp into xstr separated by '|'.
    endif.
  enddo.
  append xstr to istr.

endloop.

call method cl_gui_frontend_services=>gui_download
  exporting
    filename                = 'c:test.txt'
  changing
    data_tab                = istr.

Regards,

RIch Heilman

3 REPLIES 3

Former Member
0 Kudos

hi gopi anne,

define like this,

data: it_bseg1 type string.

try to avoid this.

data : it_bseg1(4096) type c occurs 0.

reward points if helpful,

regards,

seshu.

Former Member
0 Kudos

You'll probably want to convert you currency fields to character first.

Rob

RichHeilman
Developer Advocate
Developer Advocate

Please try this example program.



report zrich_0001 .

data: ibseg type table of bseg.
data: xbseg like line of ibseg.

data: istr type table of string,
      xstr type string.
data: xtmp type string.
field-symbols: <fs>.


select * into table ibseg from bseg
           up to 100 rows.

loop at ibseg into xbseg.

  do.
    assign component sy-index of structure xbseg to <fs>.
    if sy-subrc <> 0.
      exit.
    endif.
    xtmp = <fs>.
    if sy-index = 1.
      xstr = xtmp.
    else.
      concatenate xstr xtmp into xstr separated by '|'.
    endif.
  enddo.
  append xstr to istr.

endloop.

call method cl_gui_frontend_services=>gui_download
  exporting
    filename                = 'c:test.txt'
  changing
    data_tab                = istr.

Regards,

RIch Heilman