Skip to Content
Author's profile photo Former Member

Error occuring while arrchiving the data

Hi,

Error occuring to archive data in the Customizing Program.

1        Problem Statement

 

Loads failing with the below message

   Capture.JPG

This happens in an ABAP program Z1BI_DIR_CLEANUP_INBOUND_DIR
that is supposed to move the files of the DIR project to a different location.

The file names are picked up from a table called ZMDLO_FILE_INST.

1        Investigation

 

Within Class ZMD_FILE_HDLR_DEFAULT, method _OS_COMMAND,
the following code is found

  Capture.JPG

If the FM is able to fire the OS command, the OS sends back
a status code flag and protocol messages as an internal table. The above code first
checks if the status code (ld_status) = E, meaning that the OS has returned an
error.

 

If the status code = E, it then checks the protocol messages
table and checks if the error message contains the string “No such file or”. If
it does, then the method interprets this as a scenario that the file doesn’t
exist. The method is written such that, a file-not-found situation is
considered to be fine. However, if the protocol message did not contain the
string “No such file or”, then the method considers this to be a situation of
UNKNOWN_ERROR.

To summarize

  IfProtocol message contains “No such file or”, then it is a file-not-found
situation, ignore and continue

If Protocol message doesn’t contain “No such file or”, then it is UNKNOWN, throw
an error and exit

As a result, the following error message is generated by the
OS.

 

mv: cannot stat
`/usr/sap/interfaces/WDC/ftpwdc/Transaction/Inbound/Inbox/INS_DATA_XY_XY_IndirectCustomerLakshmi_Test.csv’:
No such file or directory.

Ideally, the above error message would be
interpreted as file-not-found and would have caused the code to carry on with
the rest of the files.

 

However, the protocol table that is sent
back to ABAP has a length of 128 characters. This is standard behavior. Due to
this, the above error message gets shortened to the first 128 characters, which
are:

 

mv: cannot stat
`/usr/sap/interfaces/WDC/ftpwdc/Transaction/Inbound/Inbox/INS_DATA_XY_XY_IndirectCustomerLakshmi_Test.csv’:
No s

    

Note that the above message (which gets passed back to ABAP)
does not contain the string “No such file or”.

Due to this, ABAP interprets the cause to be UNKNOWN, and
throws an UNKNOWN ERROR

The WPC examples given in the first section will also suffer
from the same problem, as the OS-generated error message would cross 128
characters.

However, sometimes this file or path does not exist in AL11.
Note, there is no “DE” directory within ftpwpc.

Due to this the file-not-found can arise. If the
path+filename of the missing file is so long that the error message is longer
than 128 characters, the problem arises wherein the program misinterprets the
OS error message.

1        Possible Solutions

 

1.1      Option A

 

Ignore the protocol messages, as they cannot be relied on
100% to contain the “No such file” string.

Instead, explore if the OS is sending back anything in the
IMPORTING parameter exitcode = ld_code. It is possible that this exit code can
be used to detect if the cause of failure is a file-not-found situation.

Capture.JPG

This needs investigation to find what exit code can be used,
and whether that is reliable.

   

1.1      Option B

 

Use the protocol messages, but use the first part of the
string, such as below

 

Mv: cannot stat

This needs investigation to confirm that “mv: cannot stat” is
a watertight string in the error that only comes when the file is not found.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.