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: 

table conversion. Howto

Former Member
0 Kudos

hi gurus. Can someone tell if there is any FM or anybody nows a way to split a table with 1024 chars in each line into a table with 132 in each line without losing data??

Thk, regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

<b>please see this link for details explaination of splitting the data more that 132 characters into separate line </b> ...

<a href="http://">http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm</a>

reward points if it is usefull ....

Girish

8 REPLIES 8

Former Member
0 Kudos

Hi,

Try with FM: 'STRING_SPLIT_AT_POSITION'

Regards,

Bhaskar

Former Member
0 Kudos

C147_STRING_SPLIT_AT_POSITION

STRING_SPLIT

STRING_SPLIT_AT_POSITION

Check these FM's.

Regards,

Pavan P.

0 Kudos

Hi

STRING_CENTER (Obsolete) Centered a string

STRING_CONCATENATE Concatenates (links) two strings without multibyte handling

STRING_LENGTH (Onsolete) Calculate the length of a string

STRING_MOVE_RIGHT (Obsolete) Shift a string to the right

STRING_REVERSE Returns a string in reverse order

STRING_SPLIT (Obsolete) Split a string in accordance with a delimiter.

STRING_SPLIT_AT_POSITION Split a string with a proper position into two parts

check this sample code

DATA: text(10) TYPE c VALUE '0123456789',
text1(6) TYPE c,
text2(6) TYPE c.

PARAMETERS position TYPE i.

CALL FUNCTION 'STRING_SPLIT_AT_POSITION'
EXPORTING
string = text
pos = position
IMPORTING
string1 = text1
string2 = text2
EXCEPTIONS
string1_too_small = 1
string2_too_small = 2
pos_not_valid = 3
OTHERS = 4.

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

<b>please see this link for details explaination of splitting the data more that 132 characters into separate line </b> ...

<a href="http://">http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm</a>

reward points if it is usefull ....

Girish

0 Kudos

Thk for the repluys guys..

Girish Kumar Loganathan can you give me agina the url. Its giving me an bad url error

Thk, Regards

0 Kudos

hi again. Girish Kumar Loganathan i allready seen the link dont borrow with the url.

Thk for the FM guys but my problem its that i have a table where each line has 1024 chars and i want to split each line of that table into 132 line chars to another table without losing information..

Thk, Regards

0 Kudos

hello

begin of ty_tab1

line(1024) type c,

end of ty_tab1

begin of ty_tab2

line1(132) type c,

line2(132)type c,

..

line8(132) type c,

end of ty_tab2.

data: it_tab1 type table of ty_tab1, wa_tab1 type ty_tab1

it_tab2 type table of ty_tab2, wa_tab2 typ ty_tab2.

loop at it_tab1 into wa_tab1.

concatenate wa_tab1(132) into wa_tab2-line1.

concatenate wa_tab1+132(132) into wa_tab2-line2.

concatente wa_tab+264(132) into wa_tab2-line3 .

concatente wa_tab+396(132) into wa_tab2-line4 .

...

..

cancatenate wa_tab1+924(100) into wa_tab2-line8.

append wa_tab2 to it_tab2.

clear: wa_tab2,

wa_tab1.

endloop.

reward points if helpful.

raymond_giuseppi
Active Contributor
0 Kudos

Try FM TEXT_SPLIT.

Put the first record of the 1024 length table into a var.

Split it at 132

    CLEAR ZEILE.
    CALL FUNCTION 'TEXT_SPLIT'
         EXPORTING
              LENGTH = 132
              TEXT   = RESTTEXT
         IMPORTING
              LINE   = ZEILE
              REST   = RESTTEXT
         EXCEPTIONS
              OTHERS = 1.

append ZEILE to 132 length table

if REST string length is less than 132 and not end of table, append a new record of 1024 to the end

If REST string length is less than 132 and end of table, append REST to 132 length table

loop til no more text and rest is empty.

Regards