on 04-15-2006 12:27 AM
Hi friends,
can any one explain me how to read multiple data from a single file .
Like header and item details .
can anyone explain me with code.
Thank you in advacne.
Regards,
Roby.
Hi, Roby.
Sorry for my slow response, as recently is so busy.
About the problem you meet around logical file path.
Because you choose the direct input way, which will launch a SAP standard application to do inbound. But for these application, will need a import file as source. So our LSMW target file will be saved under the logical file path, and this path will be used as Direct Import File path. (hope you understand I explain clearly)
Then you can use tcode FILE to check the logical path.
It is a expression, which will be translate into a physical path at last.
E.G. logical file : <Dir>\test\<File>
<Dir> <File> is a variant which will be replaced by a something when SAP translate it. Let's assume it will be translated into MyPath\test\Import.txt
MyPath = <Dir> <File> = Import.txt
You can do a research on the tcode FILE, I think you will quick get sense from it.
And you error is occur as the logical path can't be translated successfully into physical path, in my opinion.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
good
&----
*& Chapter 26: Reading data from a file
&----
REPORT CHAP2602.
Data declarations for later use
TABLES CUSTOMERS.
PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat'
LOWER CASE.
DATA: MSG_TEXT(50),
ALL_CUSTOMER_NAMES LIKE CUSTOMERS-NAME OCCURS 100
WITH HEADER LINE.
Opening the File
OPEN DATASET FILENAME FOR INPUT IN TEXT MODE
MESSAGE MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: 'File cannot be opened. Reason:', MSG_TEXT.
EXIT.
ENDIF.
Reading Data
DO.
READ DATASET FILENAME INTO ALL_CUSTOMER_NAMES.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
APPEND ALL_CUSTOMER_NAMES.
ENDDO.
Closing the file
CLOSE DATASET FILENAME.
Display the result
LOOP AT ALL_CUSTOMER_NAMES.
WRITE / ALL_CUSTOMER_NAMES.
ENDLOOP.
thanks
Mrutyun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi tripathy,
thank you for your reply.
i am aware of the concept involved in datasets.
the problem is i am not able to understand why it is giving an error when i am giving my logical file destination . it is not able to open the standard sap program .
as the program is internally executed i mean the standard sap program , how to i rectify it .
let me know .
thanks in advance.
regards,
roby.
Hi tripathy,
thank you for your reply.
i am aware of the concept involved in datasets.
i am having a problem when i am migrating data through LSMW .
for a direct method when i gave a logical file name its not able to open the standard sap program ( rvinvb10) advising me it is not able to open the program.
i am not able to update the database .
as the program is internally executed i mean the standard sap program , how to i rectify it .
let me know .
thanks in advance.
regards,
roby.
hi, to achieve what you need, the following steps should be done
Let assume you file has two structure Head & Item.
(Head) A1
(Item) B1 B11
(Head) A2
(Item) B2 B22
Define two source structure, Head & Item. Head is top hierarchy. Item is lower level.
Then add a new field in your source structure definition.(Step Maintain Source Fields) E.G. Name 'ID'.
Then set 'Identifying Field Content' as 'H' for Head Structure.
set 'Identifying Field Content' as 'I' for Item Structure.
Till now, some change should be done in the source file content.
Like this:
(ID)
H A1
I B1 B11
H A2
I B2 B22
'ID' is the additional field we added to differentiate the structure kind. 'H' 'I' is the value to indentify.
After these, LSMW can get to know which entry in source file is Head Structure, and Which one is for Item structure.
Hope it will be helpful
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zhenglin,
Thank you , it solved my problem , but can u let me know i have got a problem once i have converted the data for the dirct input method , it is asking to give me logical file or physical file.
when i gave it and execute it , its giving me an error stating it is not able to open it .
can u let me know whats the problem is.
thanks in advance .
Regards,
Roby
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.