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

STRING INTO TABLE

Former Member
0 Likes
2,849

hI.

I got a problem....

I'm uploading texts to SAP from .txt files, but what I need is to put that string line maximun of 1024 caracters in a table with a field of 132 caracters with out cutting the words.

Does some body have had this problem?

for example:

this is a line text without "enter"

La atención médica con regularidad está fuera de la programación económica familiar y en el momento que se presenta una alteración en la salud normalmente refleja un desequilibrio económico. MédicaLife es un seguro de gastos médicos diseñado para complementar los objetivos de protección, que le brinda la oportunidad de contar con un respaldo para enfrentar los gastos que deban realizarse por accidentes o enfermedades.Relación en donde se especifica el monto máximo que pagará MetLife por cada consulta médica o procedimiento quirúrgico ya sea ENFERMEDAD o ACCIDENTE. Tabulador diferente según el plan contratado y lugar donde éste se realice. Cantidad a cargo del asegurado, que se debe pagar en cada evento por Enfermedad o Accidente. Una vez rebasada esta cantidad, comienza la obligación de MetLife. Porcentaje a cargo del asegurado, que se aplica al monto total de gastos cubiertos por Enfermedad en cada reclamación inicial o complementaria, una vez descontado el deducible. En caso de Accidente no aplica el costos

And I need to do something like this

table x

field 1

La atención médica con regularidad está

fuera de la programación económica familiar

y en el momento que se presenta una

alteración en la salud normalmente refleja

un desequilibrio económico. MédicaLife es un

seguro de gastos médicos diseñado para complementar

los objetivos de protección, que le brinda la

oportunidad de contar con un respaldo para

enfrentar los gastos que deban realizarse por

accidentes o enfermedades.Relación en donde se

especifica el monto máximo que pagará MetLife por cada

consulta médica o procedimiento quirúrgico ya sea

ENFERMEDAD o ACCIDENTE. Tabulador diferente según el

plan contratado y lugar donde éste se realice.

Cantidad a cargo del asegurado, que se debe pagar en

cada evento por Enfermedad o Accidente. Una vez

rebasada esta cantidad, comienza la obligación de

MetLife. Porcentaje a cargo del asegurado, que se

aplica al monto total de gastos cubiertos por

Enfermedad en cada reclamación inicial o

complementaria, una vez descontado el deducible.

En caso de Accidente no aplica el costos.

pleeeeeaaaaaaaaaaseeeeeeeeeee heeeeeeeeeeelllllllpmeeeeeeeeeeee :o(

7 REPLIES 7
Read only

Former Member
0 Likes
1,793

Adrian,

Use the function module RKD_WORD_WRAP and pass the text in a character variable with length of your choice.. along with the table that you want the wrapped text to put in & maximum line size for your result wrapped text.

Hope this helps.

Regards,

Nagaraju Chidurupalli

Read only

0 Likes
1,793

It works fin, but the problem is that I upload the text in a table with a field of string, so when I call the function the text passes but only 200 caracters not the 1024 that comes in the line :o(

Read only

0 Likes
1,793

Adrian,

You can have internal table with one of the fields as STRING data type. So, when you upload everything comes into one line and then you cna break that into mulitple lines as per your requirement.


TYPES : BEGIN OF TY_TAB,
        FIELD TYPE STRING,
       END OF TY_TAB.

TYPES : BEGIN OF TY_TAB1,
        FIELD TYPE CHAR1024,
       END OF TY_TAB1.

DATA : T_DATA TYPE TABLE OF TY_TAB.


PARAMETERS : P_FILE LIKE RLGRAP-FILENAME
      default 'C:Documents and SettingsrallamDesktopTest.txt'.

DATA : W_FILE TYPE STRING.
W_FILE = P_FILE.

START-OF-SELECTION.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
          EXPORTING
            FILENAME                = W_FILE
*           FILETYPE                = 'ASC'
*           HAS_FIELD_SEPARATOR     = SPACE
*           HEADER_LENGTH           = 0
*           DAT_MODE                = SPACE
*           CODEPAGE                = SPACE
*           IGNORE_CERR             = ABAP_TRUE
*           REPLACEMENT             = '#'
*           READ_BY_LINE            = 'X'
*         IMPORTING
*           FILELENGTH              =
*           HEADER                  =
    CHANGING
      DATA_TAB                = T_DATA
*         EXCEPTIONS
*           FILE_OPEN_ERROR         = 1
*           FILE_READ_ERROR         = 2
*           NO_BATCH                = 3
*           GUI_REFUSE_FILETRANSFER = 4
*           INVALID_TYPE            = 5
*           NO_AUTHORITY            = 6
*           UNKNOWN_ERROR           = 7
*           BAD_DATA_FORMAT         = 8
*           HEADER_NOT_ALLOWED      = 9
*           SEPARATOR_NOT_ALLOWED   = 10
*           HEADER_TOO_LONG         = 11
*           UNKNOWN_DP_ERROR        = 12
*           ACCESS_DENIED           = 13
*           DP_OUT_OF_MEMORY        = 14
*           DISK_FULL               = 15
*           DP_TIMEOUT              = 16
*           NOT_SUPPORTED_BY_GUI    = 17
*           ERROR_NO_GUI            = 18
*           others                  = 19
          .
  IF SY-SUBRC <> 0.
*        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

The entire contents is in only one line of the table. Now you can loop at it and break into lines.

Regards,

Ravi

Note : Please mark all the helpful answers and close the thread if the issue is resolved.

Read only

Former Member
0 Likes
1,793

Adrian,

This looks like a long text and usually these are stored in the table STXL using SAVE_TEXT / CREATE_TEXT functions with a specific TDOBJECT / TEXT NAME / TEXT ID. You can break this into lines using FORMAT_TEXTLINES / RKD_WORD_WRAP and then save it as a long text.

Even if you are able to save this into table, fetching also will be a problem. If use the long text functionality you can easily read using READ_TEXT function and can also look at this using SO10.

Regards,

Ravi

note :Please mark the helpful answers

Read only

Former Member
0 Likes
1,793

hi

good

try with the folloins function module

RKD_WORD_WRAP Convert a long string or phrase into several lines

33.POPUP_TO_GET_ONE_VALUE/POPUP_TO_FETCH_ONE_VALUE: using this function module user can pass on any string value to the program with 3 lines of text and 2 options.

thanks

mrutyun

Read only

Former Member
0 Likes
1,793

hi adrian,

you can use this sample code.

REPORT zkun_file7 .

TABLES : zkunal1.

DATA : BEGIN OF tablex OCCURS 0,

field1(132) TYPE c,

END OF tablex.

DATA : BEGIN OF gv_itab OCCURS 0,

str(3000) TYPE c,

END OF gv_itab.

*data : begin of gv_itab occurs 0,

  • fname like zkunal1-fname,

  • lname like zkunal1-lname,

  • place like zkunal1-place,

  • end of gv_itab.

DATA : gv_file TYPE string.

*****************************************************************

*SELECTION SCREEN *

*****************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE ibipparms-path OBLIGATORY. " For file selection

SELECTION-SCREEN END OF BLOCK b1.

*****************************************************************

*AT SELECTION SCREEN *

*****************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

IMPORTING

file_name = p_file.

*****************************************************************

*START OF SELECTION * *

*****************************************************************

START-OF-SELECTION.

  • P_FILE is not compatible with the FM GUI_UPLOAD, so pass it to

  • GV_FILE.

gv_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

filetype = 'ASC'

has_field_separator = '#'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = gv_itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

data : x type i.

x = 0.

LOOP AT gv_itab.

tablex-field1 = gv_itab-str+x(132).

x = x + 132.

append tablex.

endloop.

Hope this helps you.

Regards,

Kunal.

Read only

athavanraja
Active Contributor
0 Likes
1,793

did you try this FM

SOTR_SERV_STRING_TO_TABLE

Regards

Raja