Convert SAP Internal Dates to Date Format of Current User
Developing a recording-based LSMW object to be used by multiple resources during a multinational SAP implementation can be cumbersome because of user-specific date and decimal formats. If dates in the source data are expected in a certain format then ensuring that the user has the correct profile settings is enough to avoid errors caused by formatting issues.
A simpler way to prepare source data and LSMW object to be used in multiple resources in different countries. Specifying SAP's YYYYMMDD date format allows for simple manipulation in ABAP to format the date according to the profile of the user so that recording-based batches run without issue.
The CONVERT_DATE_TO_EXTERNAL
function is the simplest way to convert SAP internal dates to a format that can be used in a batch. It takes a DATUM
value and returns a non-formatted value based on the profile of the user.
MIGOM-BUDAT = MIGOS-BUDAT. ** Sample data came with dates in YYYYMMDD format. Fix that here... if MIGOS-BUDAT co '1234567890 '. "YYYYMMDD . . . move MIGOS-BUDAT to lDATUM. CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' EXPORTING date_internal = lDATUM IMPORTING date_external = MIGOM-BUDAT. endif.