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

Finding comma separated values in internal table

Former Member
0 Likes
1,378

Hi,

I am uploading one file from presentation server into one internal table.

My internal table have structure as follows:

TYPES: BEGIN OF ttab_type,

rec(1000) TYPE c,

END OF ttab_type.

After uploading into internal table I want to check if the values are comma separated or not.How to do this.Please help.

4 REPLIES 4
Read only

Former Member
0 Likes
897

Hi,

You can not find out like, the file is comma separator one or not.

Directly if you are aware like it is of comma separator one, then using the SPLIT AT C_COMMA..... you can split the values.

Few functionalities will contain like, in the header line, it may contain the separator details.

Regards,

Nangunoori.

Read only

Former Member
0 Likes
897

use a perform statement inside the loop for internal table.

loop at ttab.

PERFORM ZSTRING_CONV.

endloop.

FORM ZSTRING_CONV.

DATA: STR_LEN LIKE SY-FDPOS,

RSTR_LEN LIKE SY-FDPOS,

OFF LIKE SY-FDPOS.

DATA: IDX LIKE SY-FDPOS, "mn B20K054003

CL LIKE SY-FDPOS. "mn B20K054003

DATA: RSTRING(40).

DATA: STRING(40). " value 'A,N,I,L'.

  • data: n_char(1).

FIELD-SYMBOLS: <NLS_CHAR>. "mn B20K054003

  • field-symbols: <string>, <rstring>.

MOVE ttab-rec TO STRING.

MOVE SPACE TO RSTRING.

STR_LEN = STRLEN( STRING ).

DESCRIBE FIELD RSTRING LENGTH RSTR_LEN.

IF RSTR_LEN < STR_LEN. RAISE TOO_SMALL. ENDIF.

WHILE IDX < STR_LEN. "mn B20K054003

ASSIGN STRING+IDX(*) TO <NLS_CHAR>. "mn B20K054003

IF SY-LANGU EQ '2'. "mn B20K054003

CALL FUNCTION 'NLS_THAI_CHARLEN' "mn B20K054003

EXPORTING "mn B20K054003

THAI_STRING = <NLS_CHAR> "mn B20K054003

CHANGING "mn B20K054003

THAI_CHARLEN = CL. "mn B20K054003

ELSE. "mn B20K054003

CL = CHARLEN( <NLS_CHAR> ). "mn B20K054003

ENDIF. "mn B20K054003

IF IDX NE 0. "mn B20K054003

SHIFT RSTRING RIGHT BY CL PLACES."mn B20K054003

ENDIF. "mn B20K054003

IF STRING+IDX(CL) CA ','.

store the text into some variable

ENDIF.

RSTRING0(CL) = STRINGIDX(CL). "mn B20K054003

IDX = IDX + CL. "mn B20K054003

ENDWHILE. "mn B20K054003

ENDFORM.

Try this process. May be it could help you out.

Regds,

Anil

Read only

Former Member
0 Likes
897

U CAN USE LIKE

LOOP AT ITAB.

FIND ALL OCCURRENCES <write your logci>

ENDLOOP.

Read only

Former Member
0 Likes
897

also check the following thread