01-17-2013 6:26 AM
Dear Experts,
I have a scenario where I need to import data from file with extension '.ini' in my SAP report from Application Server. I have tried given option in other posts in this forum, but not successful. Please can you provide any FM/ SAP commands/ Code for same.
Maninder
01-17-2013 6:32 AM
hi Maninder ,
try this
DATA : p_infile LIKE rlgrap-filename VALUE 'Application server filename path. ini'.
DATA: ld_file LIKE rlgrap-filename.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: lv_string, wa , l_string.
READ DATASET ld_file INTO lv_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
wa-string = lv_string.
APPEND wa TO itab.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
and moreover you can try with T-code CG3Y
01-17-2013 6:57 AM
Yogender,
Thanks for reply.
I have tried this code as I mentioned and it does not work.
This is particular to files with Extn '.ini'.
Also, I would like to know the Mode given in attributes of file as '660' and '640'. What they signifies?
01-17-2013 9:00 AM
Hi Maninder ,
Can u explain how you are creating .ini on aplication server ? or its a default file ?
moreover ,
talking about 660 & 640 ,
this are the access granted for file to (owner, group, others) , every digit for them respectively
and
digits signify as follows :
0 no access
1 eXecute
2 Write
4 Read
now the question arises , why 6 here in 660 & 640
so , its the combination of write (2) & read (4) i.e. 2 + 4 = 6
01-17-2013 9:16 AM
Yogen,
The files are coming from Redwood and created in SAP. Thanks for explaining 660,640, but it seems not related to problem here. Kindly read my reply to Raymond and if you have resolution, Please suggest.
01-17-2013 9:28 AM
Hi maninder ,
you can try spliting the string at spaces , it would work but before that condense the string .
For help , see below code :
data : str(50) value 'Hello SAP India ', str1(10) , str2(10) , str3(10).
write : / str .
condense str.
split str at ` ` into str1 str2 str3.
write: / str.
condense : str1 , str2 , str3 .
write : / str1 .
write : / str2 .
write : / str3.
01-17-2013 11:47 AM
01-17-2013 7:20 AM
What do you mean by "not successful", do you get an error (sy-subrc), a dump (CX_SY_FILE_OPEN or similar exception), wrong data ?
Regards,
Raymond
01-17-2013 8:18 AM
Ok, Let me explain:
I am able to open the File, But The file format is a problem to me.
Data is not separated by any delimiter. In a row, column values are separated by spaces (no fix count of spaces). For example:
OK - ok ZE1100E2XZ42O001DTA 1-R 2013-01-17 05:30 ZE1/M100/D2XZ42/out/DTA/R1DE_SCM_PFU_IF_075* DA8063 P1
Now I want all these values in separate columns. I tried below statement:
data: w_char(1) type c value cl_abap_char_utilities=>horizontal_tab.
SPLIT w_data AT w_char INTO lv_string
lv_string2
lv_string3
lv_string4
lv_string.
But it is not working. Kindly help me. Please ask for more information if needed.
01-17-2013 8:55 AM
Check via debug, is it an actual space or another character like CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB, VERTICAL_TAB, NEWLINE or CR_LF.
For information Unicode has technically 26 values for "whitespace" (Unicode 6.0, Chapter 4.6)
(You are unlikely to Meet most of them in one .ini configurarion file)
Regards,
Raymond
01-17-2013 9:12 AM
Raymond,
Seems very good information.
Additionally, I would like to know If we can read values in a way such that non-space values are stored in columns and spaces are skipped. For ex: OK is stored in first column, and then all spaces (any count, doesn't matter) are skipped and next value is stored in 2nd column untill next bunch of spaces are encountered.
Hope the logic is clear.
01-17-2013 12:16 PM
Try to replace all "exotic" spaces with ascii basic space, then SPLIT AT space INTO internal table.
You could start with a
CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
EXPORTING
intext = text
IMPORTING
outtext = text.
CONDENSE text.
SPLIT text AT space INTO TABLE itab.
Look also if some "exotic" spaces were not removed by the FM.
Regards,
Raymond