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

function SPLIT_LINE not working as expected

Former Member
0 Likes
1,598

Dear All,

I have created a BDC to upload Long Text of CJ20N along with the Dates. For this first the editable ALV is used where in the User can enter Long Text. It is working fine. I have used the below FM to split the text after every 50 characters but it is not working properly

CALL FUNCTION 'SPLIT_LINE'

EXPORTING

TEXT = W_TEMPUPLOAD-REM " Long Text

LEN = TLEN " Total Length of String

MAXLEN = 50

TABLES

RESULT_TAB = LT_RESULT_TAB.

L_LINES-TDFORMAT = ''.

L_LINES-TDLINE = ''.

APPEND L_LINES .

It is breaking text of length 128 from 42 ,50,34 characters one by one . It is not working fine. also it is not uploading it correctly . Say for eg the word 'asked' is written then it is uploading 'aske'.

Please guide me in this matter.

Regards,

Bharti Jain

10 REPLIES 10
Read only

vijaymanikandan
Contributor
0 Likes
1,268

Hi Bharati,

Kindly try to use TR_SPLIT_TEXT. This will work perfectly.

DATA: lv_text(140),

lt_lines TYPE trtexts,

ls_line TYPE trtext.

lv_text = 'TEST123456789'.

CALL FUNCTION 'TR_SPLIT_TEXT'

EXPORTING

IV_TEXT = lv_text

IV_LEN = 10

IMPORTING

ET_LINES = lt_lines

.

loop at lt_lines into ls_line.

write: ls_line.

endloop.

Br,

Vijay V

Read only

Former Member
0 Likes
1,268

Hi,

please check fm SPLIT_LINE in SE37 test mode (F8). It will work fine.

My test parameters:

TEXT SDFVHKWHFVKWHFKJWHFKHWEFKHFKHFKWHKFWHFKWHFHKWEFFHKWEHFKHKFWEHFHKWHFKWEFHKWEFHKFEHKFHKFHKWEHFKHEWKFHKWEH

LEN 160

MAXLEN 50

SEPARATOR ~

Other parameters with default value.

Regards,

Klaus

Read only

Harsh_Bansal
Contributor
0 Likes
1,268

Hi,

I have created a demo.

You can refer this and create your own FM for this purpose -


PARAMETERS: po_text TYPE char255,
            po_len  TYPE i.
DATA: wa_line TYPE char255,
      i_line TYPE STANDARD TABLE OF char255.

DATA: w_length TYPE i,
      w_mod TYPE i,
      w_count TYPE i.

w_length = STRLEN( po_text ).
w_mod = w_length mod po_len.
w_count = w_length / po_len.
IF ( w_mod NE 0 ).
  w_count = w_count + 1.
ENDIF.

CLEAR: w_mod.
DO w_count TIMES.
  wa_line = po_text+w_mod(po_len).
  APPEND wa_line TO i_line.
  w_mod = w_mod + po_len.
ENDDO.

Regards,

Harsh Bansal

Read only

Former Member
0 Likes
1,268

Dear All,

Thanks For Replying,

I have the below text:-

Order placed for Gualcheirani Baler. Civil structural drawing being prepared and vendor asked to resolve the issue as soon as possible.

After upload it will be as below

Order placed for Gualcheirani Baler. Civil structural drawin being prepared and vendor aske to resolve the issue as soon as possible. " Consider drawing and asked word before and after upload.

After upload when I see in CJ20N

then it will be as below:-

Order placed for Gualcheirani Baler. Civil

structural drawin being prepared and vendor aske

to resolve the issue as soon as possible

Please guide me,

Regards,

Bharti Jain

Read only

Harsh_Bansal
Contributor
0 Likes
1,268

Hi,

Text is coming like this after you split it using your SPLIT_LINE FM??

Use the code i have provided. I have tested it with your text.

Regards,

Harsh Bansal

Read only

0 Likes
1,268

Did you try to use the FM .TR_SPLIT_TEXT. ?

Read only

Former Member
0 Likes
1,268

It is not working fine. also it is not uploading it correctly . Say for eg the word 'asked' is written then it is uploading 'aske'.

Then, you need to fix the problem with the upload first, then try the split line FM.

Read only

Former Member
0 Likes
1,268

Dear All,

With FM 'TR_SPLIT_TEXT' the text is splitting properly but I also want to save it in CJ20N. I have used FM 'CREATE_TEXT' for it. But it is now giving dump because ET_LINES of TR_SPLIT_TEXT FM is not a structure or an internal table it is a line type so I cannot pass it in FLINES for FM 'CREATE_TEXT'

Please guide me in this matter.

Regards,

Bharti Jain

Read only

0 Likes
1,268

Hi

Try this as below and pass gt_tdline into your CREATE_TEXT.

data: gt_tdline TYPE STANDARD TABLE OF tline,

gs_tdline TYPE tline.

DATA: lv_text(140),

lt_lines TYPE trtexts,

ls_line TYPE trtext.

lv_text = 'TEST123456789'.

CALL FUNCTION 'TR_SPLIT_TEXT'

EXPORTING

IV_TEXT = lv_text

IV_LEN = 10

IMPORTING

ET_LINES = lt_lines

.

loop at lt_lines into ls_line.

write: ls_line.

endloop.

loop at lt_lines into ls_line.

move ls_line to gs_tdline-tdline.

gs_tdline-tdformat = '*'.

APPEND gs_tdline TO gt_tdline.

endloop.

Regards,

Vijay V

Read only

Harsh_Bansal
Contributor
0 Likes
1,268

Hi,

Refer this -


PARAMETERS: po_text TYPE STRING,
            po_len  TYPE i.
DATA: wa_line TYPE char255,
      i_line TYPE STANDARD TABLE OF char255.

DATA: w_length TYPE i,
      w_mod TYPE i,
      w_count TYPE i,
      w_check TYPE i.

w_length = STRLEN( po_text ).
w_mod = w_length mod po_len.
w_count = w_length / po_len.
IF ( w_mod NE 0 ).
  w_count = w_count + 1.
ENDIF.

CLEAR: w_mod.
DO w_count TIMES.
  w_check = w_mod + po_len.
  IF w_check GT w_length.
    po_len = w_length - w_mod.
  ENDIF.
  wa_line = po_text+w_mod(po_len).
  APPEND wa_line TO i_line.
  w_mod = w_mod + po_len.
ENDDO.

CALL FUNCTION 'CREATE_TEXT'
  EXPORTING
    fid               = 'AVOT'
    flanguage         = 'E'
    fname             = 'WA_AFVC-CON3'
    fobject           = 'AUFK'
*   SAVE_DIRECT       = 'X'
*   FFORMAT           = '*'
  tables
    flines            = i_line
* EXCEPTIONS
*   NO_INIT           = 1
*   NO_SAVE           = 2
*   OTHERS            = 3
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Change details in Create_text according to your need.

Regards,

Harsh Bansal