‎2009 Jul 16 5:24 AM
Hello All,
i have value like 16173 / 0180 / KLASSIK D/300 L258D VERN in flat file.
now i need only first two value that is 16173 / 0180.
How can i find first two value.
Have a Nice Day,
Regards,
Sujeet
‎2009 Jul 16 5:30 AM
If the length is fixed as per you requirement, then you can use variable(10) to fetch this value.
Otherwise use STRLEN Function to fetch the number of characters from left side by tracing the location of '/'.
regds,
Anil
‎2009 Jul 16 5:32 AM
Hi Sujeet how r u,
TRY this,
data: v1(60) type c value '16173 / 0180 / KLASSIK D/300 L258D VERN'.
data: v2(60) type c,
v3(60) type c,
vfinal(60) type c.
v1 = '16173 / 0180 / KLASSIK D/300 L258D VERN'.
v2 = v1+0(7).
v3 = v1+8(5).
CONCATENATE V2 V3 INTO VFINAL SEPARATED BY SPACE.
write: / vfinal.Rgrds,
Nikhil.
‎2009 Jul 16 5:37 AM
Hello Nikhil,
Do u think that flat file has fixed variables as i have written above??
the logic you have suggested me will never work for my requirement, as data is not in any structure, so we cant image the length.
Regards,
Sujeet
‎2009 Jul 16 5:39 AM
Hello
Try this code:
data: str(50) type c,
val(50) type c,
cnt type i,
pir type i,
counter type i.
str = '16173 / 0180 / KLASSIK D/300 L258D VERN'.
cnt = strlen( str ).
do cnt times.
if str+counter(1) = '/'.
pir = pir + 1.
endif.
if pir = 2.
exit.
endif.
counter = counter + 1.
enddo.
counter = counter - 1.
CALL FUNCTION 'COPI_STRING_SPLIT'
EXPORTING
string = str
length = counter
IMPORTING
line = val.
write val.
‎2009 Jul 16 5:44 AM
Hello Sujeet,
If your length is not fixed than you are right my logic want ne useful which you haven't mentioned in your post than you need to use the logic of split which has been already posted.
Regrds,
Nikhil.
‎2009 Jul 16 5:52 AM
‎2009 Jul 16 5:39 AM
Dear Sujeet ,
You can use "SPLIT" for the same.
You read the string in the Work area. Now Split that work area at "/".
E,g :
SPLIT WA_LINE AT '§' INTO
IT_INPUT-ROLE
IT_INPUT-GROUP
IT_INPUT-CATEGORY
IT_INPUT-CLASSIFY
IT_INPUT-TITLE
IT_INPUT-FIRST_NAME .
Append IT_INPUT.
Regards,
Nikhil