Upload
Open purchase orders
The bapi BAPI_PO_CREATE1 used to
upload the Open Purchase Order. The input file is as extracted file.
- Use the function module, ‘KD_GET_FILENAME_ON_F4’ to
get F4 (help) and get to the file to select the file from the location.
- Convert the file in the Excel format to SAP,
Internal Table format using ‘TEXT_CONVERT_XLS_TO_SAP’.
- Map the values for the fields ZTERM, LIFNR, KOSTL,
KSCHL, MWSKZ, and SAKTO.
- Loop the converted internal table and move the
values to corresponding internal tables like header data internal table, item
data internal table, Schedule line internal table, Condition type internal
table, Account Assignment into an internal table, service line item into an
internal table. Do the Validation by mapping the field values for fields using
Custom tables.
- Loop the header data internal table and item data
internal table, schedule line internal table, Account Assignments internal
table, Service line item internal table and Condition type internal table and
move the values to the values to particular BAPI internal table and append it.
- Call the BAPI and capture the return , check for if
SY_SUBRC EQ ‘0’, then update in the custom table and update into an internal
table, else update into an internal table.
- Download the internal table using GUI_DOWNLOAD
function module with header text.
Upload Open purchase orders Text.
To upload the Open Purchase Order
Text, Input file is as extracted file.
- Use the function module, ‘FAA_FILE_F4’ to get F4
(help) and get to the file to select the file from the location.
- Convert the file in the Excel format to SAP,
Internal Table format using ‘GUI_UPLOAD’.
- Get the file into an internal table, loop the
internal table do the Conversion exit for EBELN and EBELP.
- Get the Text id into a variable, Calculate the
length of the text using ‘strlen’.
- Then do the Calculation, if String length is greater
than 132, get variable mod = strlen MOD 132.
- If variable mod = 0, N = strlen/132. Else Mod is
greater than 0, strlen = strlen – mod, N = Strlen/132 and N = N +1 and end if
statement.
- Move length = 132, else N = 1 and length = Strlen
and end if statement.
- DO N times, Move the Work area text into an internal
table and append it. Calculate and off 132 characters into the work area.
- Then move the header details, EBELN, EBELP, TEXT ID,
TD OBJECT = ‘EKKO’ and Language = SY-LANGU.
- Use ‘SAV_TEXT’ Function Module, by moving all header
details and internal table having long text.
- In the same way repeat the procedure for Item Text
and SAVE the text using SAVE_TEXT Function Module.
- Check for the SY-SUBRC, if SY-SUBRC EQ 0 Move the
Text Successfully Saved into a Work area as message else Move text not saved
successfully into an work area and append the internal table.
- Download the internal table using ‘GUI_DOWNLOAD’ as
excel file.
Limitations:
- The input File should not contain records more than 4000.
- It’s better to validate the input file unit with standard SAP MARA table
unit, before upload.