03-21-2007 3:14 AM
How To use 'BAPI_GOODSMVT_CREATE' to post Goods Reciept-Inbound Delivery Just like as t-code 'MIGO'.
thanks
03-21-2007 3:59 AM
Hi Razer,
Please refer the link,
http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm
Best Regards.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 11, 2008 5:17 PM
02-11-2008 8:31 PM
Hi,
Did you got any solution of this??? I have to implement this same... Can you please pass me more info on this
Thanks in Advance
02-11-2008 9:24 PM
use the following code:
*******************************Main program****************************************
REPORT zsccp1014r MESSAGE-ID zp1_sc_001
LINE-SIZE 255
LINE-COUNT 65
NO STANDARD PAGE HEADING.
INCLUDE zsccp1014t. "Include for Data Declarations.
INCLUDE zsccp1014f. "Include for Subroutines.
----
*At Selection-Screen on value-request
----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_gm_fl.
PERFORM f_file_selection. "Subroutine for file selection for Inventory upload
----
*Top-Of-Page
----
TOP-OF-PAGE.
PERFORM f_header. "Subroutine for Display Report Output.
----
*Start-Of-Selection
----
START-OF-SELECTION.
WRITE 😕 sy-uline.
IF p_gm_fl IS INITIAL.
SET CURSOR FIELD c_gm_fl.
MESSAGE i900 DISPLAY LIKE c_error. "Error when file name is not given.
LEAVE LIST-PROCESSING.
ENDIF.
IF p_lines IS INITIAL.
SET CURSOR FIELD c_lines.
MESSAGE i906 DISPLAY LIKE c_error. "Error when value for line item per document has not entered.
LEAVE LIST-PROCESSING.
ENDIF.
PERFORM f_upload_file. "Subroutine for upload Inventory file
PERFORM f_run_bapi. "Subroutine for executing the Standard BAPI for uploading Inventory data.
----
End-Of-Selection
----
END-OF-SELECTION.
IF NOT i_error[] IS INITIAL.
IF p_lines = 1.
PERFORM f_download_error_file_single. "Subroutine for Downloading the Error Text File for single lines.
PERFORM f_display_error_single. "Subroutine for displaying the Error Log as output for single lines.
ELSE.
PERFORM f_download_error_file_multiple. "Subroutine for Downloading the Error Text File for multiple lines.
PERFORM f_display_error_multiple. "Subroutine for displaying the Error Log as output for multiple lines.
ENDIF.
ENDIF.
IF NOT i_success[] IS INITIAL.
PERFORM f_display_success_goodsmvt. "Subroutine for displaying the count of success Inventory data uploaded in SAP.
ENDIF.
************************************************************************************
***********Include zsccp1014t*********************************************
----
Selection Screen
----
SELECTION-SCREEN BEGIN OF BLOCK upl WITH FRAME TITLE text-t01.
PARAMETERS: rb_pc RADIOBUTTON GROUP upl DEFAULT 'X' USER-COMMAND upl, "Radio Button for Presentation Server.
rb_ux RADIOBUTTON GROUP upl, "Radio Button for Application Server.
p_lines TYPE i, "line items per document
p_gm_fl TYPE cffile-filename, "File Name and Path for Inventory Upload.
p_err_fl TYPE cffile-filename DEFAULT 'C:\Inventory_Error.txt'. "Error File Name and Path for Inventory download.
SELECTION-SCREEN END OF BLOCK upl.
----
CONSTANTS / VARIABLES *
----
CONSTANTS:c_read TYPE dxfields-fileoper VALUE 'R',
c_applic TYPE dxfields-location VALUE 'A',
c_presen TYPE dxfields-location VALUE 'P',
c_gm_fl(8) TYPE c VALUE 'P_GM_FL',
c_lines(8) TYPE c VALUE 'P_LINES',
c_root(01) TYPE c VALUE '/',
c_error(1) TYPE c VALUE 'I',
c_filetype(3) TYPE c VALUE 'ASC',
c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab,
c_x(1) TYPE c VALUE 'X',
c_ty(2) TYPE c VALUE 'E',
c_ap_path(31) TYPE c VALUE '/conversion/in/SC/CNV-014/comm/'.
----
TYPES *
----
TYPES: BEGIN OF t_goodsmvt, "Structure for Inventory legacy fields.
plant TYPE bapi2017_gm_item_create-plant, "Plant
stge_loc TYPE bapi2017_gm_item_create-stge_loc, "Storage location
material TYPE bapi2017_gm_item_create-material, "Material Number
serialno TYPE bapi2017_gm_serialnumber-serialno, "Serial Number
entry_uom TYPE bapi2017_gm_item_create-entry_uom, "Unit of Entry
move_type TYPE bapi2017_gm_item_create-move_type, "Movement Type
entry_qnt(13) TYPE c, "Quantity
val_type TYPE bapi2017_gm_item_create-val_type, "valuation type
ean_upc TYPE EQUNR, "SIR847
END OF t_goodsmvt,
BEGIN OF t_error, "Structure for error fields
plant TYPE bapi2017_gm_item_create-plant, "Plant
stge_loc TYPE bapi2017_gm_item_create-stge_loc, "Storage location
material TYPE bapi2017_gm_item_create-material, "Material Number
serialno TYPE bapi2017_gm_serialnumber-serialno, "Serial Number
entry_uom TYPE bapi2017_gm_item_create-entry_uom, "Unit of Entry
move_type TYPE bapi2017_gm_item_create-move_type, "Movement Type
entry_qnt(13) TYPE c, "Quantity
val_type TYPE bapi2017_gm_item_create-val_type, "valuation type
err_desc(100) TYPE c, "Error description
err_msgtype(1) TYPE c, "Error message type
err_msgnum(3) TYPE c, "Error message Number
END OF t_error,
BEGIN OF t_success, "Structure for Inventory legacy fields.
plant TYPE bapi2017_gm_item_create-plant, "Plant
stge_loc TYPE bapi2017_gm_item_create-stge_loc, "Storage location
material TYPE bapi2017_gm_item_create-material, "Material Number
serialno TYPE bapi2017_gm_serialnumber-serialno, "Serial Number
entry_uom TYPE bapi2017_gm_item_create-entry_uom, "Unit of Entry
move_type TYPE bapi2017_gm_item_create-move_type, "Movement Type
entry_qnt(13) TYPE c, "Quantity
val_type TYPE bapi2017_gm_item_create-val_type, "valuation type
mat_doc TYPE bapi2017_gm_head_ret-mat_doc, "Material Document No.
doc_year TYPE bapi2017_gm_head_ret-doc_year,
recordno TYPE i,
END OF t_success,
BEGIN OF t_error_output,
material TYPE bapi2017_gm_item_create-material, "Material Number
serialno TYPE bapi2017_gm_serialnumber-serialno, "Serial Number
entry_uom TYPE bapi2017_gm_item_create-entry_uom, "Unit of Entry
plant TYPE bapi2017_gm_item_create-plant, "Plant
stge_loc TYPE bapi2017_gm_item_create-stge_loc, "Storage location
move_type TYPE bapi2017_gm_item_create-move_type, "Movement Type
entry_qnt(13) TYPE c, "Quantity
val_type TYPE bapi2017_gm_item_create-val_type, "valuation type
END OF t_error_output,
BEGIN OF t_file, " To read unix file
line TYPE string,
END OF t_file.
----
WORK AREA DECLARATION *
----
DATA : wa_file TYPE t_file,
wa_goodsmvt TYPE t_goodsmvt,
wa_error TYPE t_error,
wa_return TYPE bapiret2,
wa_goodsmvt_item TYPE bapi2017_gm_item_create,
wa_goodsmvt_serialnumber TYPE bapi2017_gm_serialnumber,
wa_goodsmvt_headret TYPE bapi2017_gm_head_ret,
wa_goodsmvt_header TYPE bapi2017_gm_head_01,
wa_goodsmvt_code TYPE bapi2017_gm_code,
wa_success TYPE t_success,
wa_error_final TYPE t_goodsmvt,
wa_error_output TYPE t_error_output.
----
DATA DECLARATIONS *
----
DATA : v_line TYPE i.
DATA : v_line1 TYPE i.
DATA : v_line2 TYPE i.
DATA : v_line3 TYPE i.
DATA : v_filename TYPE string,
v_message TYPE string,
v_itab_line TYPE string.
DATA : v_count(8) TYPE c VALUE 1.
----
INTERNAL TABLE STRUCTURES *
----
DATA : i_file TYPE STANDARD TABLE OF t_file, "Internal table for legacy fields.
i_goodsmvt TYPE STANDARD TABLE OF t_goodsmvt, "Internal table for Inventory data fields.
i_error TYPE STANDARD TABLE OF t_error, "Internal table for errors.
i_return TYPE STANDARD TABLE OF bapiret2, "Internal table for return messages.
i_goodsmvt_item TYPE STANDARD TABLE OF bapi2017_gm_item_create, "Internal table for Inventory data to be passed to BAPI.
i_goodsmvt_serialnumber TYPE STANDARD TABLE OF bapi2017_gm_serialnumber, "Internal table for Serial number field.
i_goodsmvt_headret TYPE STANDARD TABLE OF bapi2017_gm_head_ret, "Internal table for material document field.
i_goodsmvt_header TYPE STANDARD TABLE OF bapi2017_gm_head_01, "Internal table for header fields.
i_goodsmvt_code TYPE STANDARD TABLE OF bapi2017_gm_code, "Internal table for code fields.
i_success TYPE STANDARD TABLE OF t_success, "Internal table for successful records.
i_error_final TYPE STANDARD TABLE OF t_goodsmvt, "Internal table for Error records
i_error_output TYPE STANDARD TABLE OF t_error_output. "Internal table for Error records in error file.server
*******************************************************************************************
****************************Include zsccp1014f***************************************
&----
*& Include ZSCCP1014F
&----
&----
*& Form f_file_selection
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_file_selection .
CONSTANTS: lc_slash(2) TYPE c VALUE '//'.
DATA : lv_file_path TYPE dxfields-longpath,
lv_location TYPE dxfields-location,
lv_server TYPE msxxlist-name,
ls_rfcsi TYPE rfcsi.
CLEAR:lv_server,lv_location, lv_file_path.
MOVE c_read TO lv_file_path.
IF lv_file_path IS INITIAL.
lv_file_path = c_root.
ENDIF.
IF NOT rb_pc IS INITIAL.
lv_location = c_presen. "If application server is selected
ELSE.
lv_location = c_applic. "If presentation server is selected
ENDIF.
IF lv_location = c_applic.
lv_file_path = c_ap_path.
ENDIF.
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION' "Allows us to browse the file either in application or presentation
EXPORTING
i_location_flag = lv_location
i_server = lv_server
i_path = lv_file_path
fileoperation = rb_pc
IMPORTING
o_path = lv_file_path
EXCEPTIONS
rfc_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
EXIT.
ELSE.
MOVE lv_file_path TO p_gm_fl.
ENDIF.
IF p_gm_fl(2) EQ lc_slash.
SHIFT p_gm_fl LEFT.
ENDIF.
ENDFORM. " gf_file_selection
----
*& Form gf_header
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_header .
NEW-LINE. " Display the header section
ULINE.
WRITE: AT /1 text-006,17 sy-repid,
30 text-007,sy-datum,
50 text-008,sy-timlo,
70 text-009, 82 p_gm_fl.
ULINE.
NEW-LINE.
NEW-LINE.
ENDFORM. " f_header
&----
*& Form f_upload_file
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_upload_file .
DATA:lv_pfile TYPE string.
CLEAR: i_goodsmvt, i_file, lv_pfile.
REFRESH: i_goodsmvt, i_file.
IF NOT rb_pc IS INITIAL. "IF the data is available on the presentation server then get the data
lv_pfile = p_gm_fl.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_pfile
filetype = 'ASC'
TABLES
data_tab = i_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE s901 DISPLAY LIKE c_error. "Error opening the file
LEAVE LIST-PROCESSING.
WHEN 2.
MESSAGE s902 DISPLAY LIKE c_error. "Error reading the file
LEAVE LIST-PROCESSING.
WHEN OTHERS.
MESSAGE s903 DISPLAY LIKE c_error.
ENDCASE.
ENDIF.
ELSE. "APPLICATION SERVER
OPEN DATASET p_gm_fl FOR INPUT IN TEXT MODE ENCODING DEFAULT "If the data is available on the UNIX/Appl. server get the data
WITH SMART LINEFEED.
IF sy-subrc NE 0.
MESSAGE s901 DISPLAY LIKE c_error. "Error opening the file
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET p_gm_fl INTO wa_file-line. "Read file which is opened.
IF sy-subrc EQ 0.
APPEND wa_file TO i_file.
ELSE.
EXIT.
ENDIF.
CLEAR wa_file.
ENDDO.
CLOSE DATASET p_gm_fl.
ENDIF.
LOOP AT i_file INTO wa_file.
PERFORM lf_f_split_upload_data USING wa_file-line. "Splitting the data into columns of internal table
CLEAR wa_file.
ENDLOOP.
ENDFORM. " f_upload_file
&----
*& Form lf_f_split_upload_data
&----
text
----
-->P_W_FILE_LINE text
----
FORM lf_f_split_upload_data USING x_lv_string TYPE string.
SPLIT x_lv_string AT c_tab INTO
wa_goodsmvt-material
wa_goodsmvt-serialno
wa_goodsmvt-entry_uom
wa_goodsmvt-plant
wa_goodsmvt-stge_loc
wa_goodsmvt-move_type
wa_goodsmvt-entry_qnt
wa_goodsmvt-val_type
wa_goodsmvt-ean_upc. "SIR847
APPEND wa_goodsmvt TO i_goodsmvt. "Appending the record into the internal table
CLEAR wa_goodsmvt.
ENDFORM. " lf_f_split_upload_data
&----
*& Form f_run_bapi
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_run_bapi .
IF NOT i_goodsmvt[] IS INITIAL.
DELETE i_goodsmvt WHERE plant = ' ' AND "Deleting the blank records into the internal table
stge_loc = ' ' AND
material = ' ' AND
serialno = ' ' AND
entry_uom = ' ' AND
move_type = ' ' AND
entry_qnt = ' ' AND
val_type = ' '. "SIR847
val_type = ' ' AND "SIR847
ean_upc = ' '. "SIR847
ENDIF.
SORT i_goodsmvt BY plant stge_loc. "Sorting the internal table by plant and storage loc.
DESCRIBE TABLE i_goodsmvt LINES v_line3 .
LOOP AT i_goodsmvt INTO wa_goodsmvt.
wa_goodsmvt_serialnumber-matdoc_itm = v_count.
PERFORM f_populate_goodsmvt_item.
PERFORM f_populate_goodsmvt_serialno.
wa_goodsmvt_header-pstng_date = sy-datum.
wa_goodsmvt_code-gm_code = '05'.
IF p_lines = 1.
PERFORM f_bapi_single.
ELSE.
AT END OF stge_loc.
PERFORM f_bapi_multiple.
ENDAT.
IF v_count = p_lines.
PERFORM f_bapi_multiple.
ENDIF.
ENDIF.
v_count = v_count + 1.
ENDLOOP.
ENDFORM. " f_run_bapi.
&----
*& Form f_bapi_single
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_bapi_single.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "Standard BAPI for pasting Inventory data.
EXPORTING
goodsmvt_header = wa_goodsmvt_header
goodsmvt_code = wa_goodsmvt_code
IMPORTING
goodsmvt_headret = wa_goodsmvt_headret
TABLES
goodsmvt_item = i_goodsmvt_item
goodsmvt_serialnumber = i_goodsmvt_serialnumber
return = i_return.
LOOP AT i_return INTO wa_return WHERE type = c_ty.
PERFORM f_populate_error_single.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. "Prevents changes being written to the database.
ENDLOOP.
IF sy-subrc = 4.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "Writes changes to the database.
EXPORTING
wait = c_x.
PERFORM f_populate_success.
ENDIF.
REFRESH i_return.
CLEAR i_return.
REFRESH i_goodsmvt_item.
CLEAR: i_goodsmvt_item,
wa_error_final.
REFRESH i_goodsmvt_serialnumber.
CLEAR i_goodsmvt_serialnumber.
CLEAR : wa_goodsmvt_header,
wa_goodsmvt_code,
wa_goodsmvt_headret,
wa_error.
CLEAR v_count.
ENDFORM. "f_bapi_single
&----
*& Form f_bapi_multiple
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_bapi_multiple.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "Standard BAPI for pasting Inventory data.
EXPORTING
goodsmvt_header = wa_goodsmvt_header
goodsmvt_code = wa_goodsmvt_code
IMPORTING
goodsmvt_headret = wa_goodsmvt_headret
TABLES
goodsmvt_item = i_goodsmvt_item
goodsmvt_serialnumber = i_goodsmvt_serialnumber
return = i_return.
LOOP AT i_return INTO wa_return WHERE type = c_ty.
PERFORM f_populate_error_multiple.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. "Prevents changes being written to the database.
ENDLOOP.
IF sy-subrc = 4.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "Writes changes to the database.
EXPORTING
wait = c_x.
PERFORM f_populate_success.
ELSE. "If BAPI returns the eror records
IF NOT i_goodsmvt_item[] IS INITIAL.
LOOP AT i_goodsmvt_item INTO wa_goodsmvt_item.
MOVE-CORRESPONDING wa_goodsmvt_item TO wa_error_final.
READ TABLE i_goodsmvt_serialnumber INTO wa_goodsmvt_serialnumber INDEX sy-tabix.
MOVE wa_goodsmvt_serialnumber-serialno TO wa_error_final-serialno.
APPEND wa_error_final TO i_error_final.
ENDLOOP.
ENDIF.
ENDIF.
REFRESH i_return.
CLEAR i_return.
REFRESH i_goodsmvt_item.
CLEAR: i_goodsmvt_item,
wa_error_final.
REFRESH i_goodsmvt_serialnumber.
CLEAR i_goodsmvt_serialnumber.
CLEAR : wa_goodsmvt_header,
wa_goodsmvt_code,
wa_goodsmvt_headret,
wa_error.
CLEAR v_count.
ENDFORM. "f_bapi_multiple
&----
*& Form f_display_error_single
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_display_error_single .
WRITE:/ text-024,15 text-025,30 text-026,48 text-021,65 text-022,80 text-023.
LOOP AT i_error INTO wa_error.
WRITE:/ wa_error-err_msgtype,15 wa_error-err_msgnum,30 wa_error-material,48 wa_error-plant,65 wa_error-stge_loc,80 wa_error-err_desc.
ENDLOOP.
ULINE.
DESCRIBE TABLE i_error LINES v_line.
WRITE:/ text-003, 55 v_line.
DESCRIBE TABLE i_goodsmvt LINES v_line1.
WRITE:/ text-004, 55 v_line1.
DESCRIBE TABLE i_success LINES v_line2.
WRITE:/ text-005, 55 v_line2.
ULINE.
CLEAR : v_line, v_line1, v_line2.
FREE:i_error.
ENDFORM. " f_display_error_single
&----
*& Form f_display_error_multiple
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_display_error_multiple .
WRITE:/ text-024,20 text-025,40 text-021,60 text-022,80 text-023.
LOOP AT i_error INTO wa_error.
WRITE:/ wa_error-err_msgtype,20 wa_error-err_msgnum,40 wa_error-plant,60 wa_error-stge_loc,80 wa_error-err_desc.
ENDLOOP.
ULINE.
DESCRIBE TABLE i_error LINES v_line.
WRITE:/ text-003, 55 v_line.
DESCRIBE TABLE i_goodsmvt LINES v_line1.
WRITE:/ text-004, 55 v_line1.
DESCRIBE TABLE i_success LINES v_line2.
WRITE:/ text-005, 55 v_line2.
ULINE.
CLEAR : v_line, v_line1, v_line2.
FREE:i_error.
ENDFORM. " f_display_error_multiple
&----
*& Form f_download_error_file_single
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_download_error_file_single .
IF NOT p_err_fl IS INITIAL.
LOOP AT i_error INTO wa_error.
MOVE-CORRESPONDING wa_error TO wa_error_output.
APPEND wa_error_output TO i_error_output.
ENDLOOP.
v_filename = p_err_fl.
IF rb_pc EQ 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_filename
write_field_separator = 'X'
TABLES
data_tab = i_error_output
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE s904 DISPLAY LIKE c_error. "Error writing the file
LEAVE LIST-PROCESSING.
WHEN OTHERS.
MESSAGE s903 DISPLAY LIKE c_error.
ENDCASE.
ENDIF.
ELSE.
OPEN DATASET v_filename FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT MESSAGE v_message.
IF sy-subrc NE 0.
"Error opening the file
MESSAGE v_message TYPE 'I'.
ELSE.
LOOP AT i_error_output INTO wa_error_output.
CONCATENATE wa_error_output-material
wa_error_output-serialno
wa_error_output-entry_uom
wa_error_output-plant
wa_error_output-stge_loc
wa_error_output-move_type
wa_error_output-entry_qnt
wa_error_output-val_type
INTO v_itab_line
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
TRANSFER v_itab_line TO v_filename.
IF sy-subrc NE 0.
MESSAGE i905 DISPLAY LIKE c_error. "Error transfering the file
ENDIF.
CLEAR: wa_error_output.
ENDLOOP.
ENDIF.
CLOSE DATASET v_filename.
ENDIF.
ENDIF.
ENDFORM. " f_download_error_file_single.
&----
*& Form f_download_error_file_multiple
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_download_error_file_multiple .
IF NOT p_err_fl IS INITIAL.
LOOP AT i_error_final INTO wa_error_final.
MOVE-CORRESPONDING wa_error_final TO wa_error_output.
APPEND wa_error_output TO i_error_output.
ENDLOOP.
v_filename = p_err_fl.
IF rb_pc EQ 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_filename
write_field_separator = 'X'
TABLES
data_tab = i_error_output
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE s904 DISPLAY LIKE c_error. "Error writing the file
LEAVE LIST-PROCESSING.
WHEN OTHERS.
MESSAGE s903 DISPLAY LIKE c_error.
ENDCASE.
ENDIF.
ELSE.
OPEN DATASET v_filename FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT MESSAGE v_message.
IF sy-subrc NE 0.
"Error opening the file
MESSAGE v_message TYPE 'I'.
ELSE.
LOOP AT i_error_output INTO wa_error_output.
CONCATENATE wa_error_output-material
wa_error_output-serialno
wa_error_output-entry_uom
wa_error_output-plant
wa_error_output-stge_loc
wa_error_output-move_type
wa_error_output-entry_qnt
wa_error_output-val_type
INTO v_itab_line
SEPARATED BY c_tab.
TRANSFER v_itab_line TO v_filename.
IF sy-subrc NE 0.
MESSAGE i905 DISPLAY LIKE c_error. "Error transfering the file
ENDIF.
CLEAR: wa_error_output.
ENDLOOP.
ENDIF.
CLOSE DATASET v_filename.
ENDIF.
ENDIF.
ENDFORM. " f_download_error_file_multiple.
&----
*& Form f_display_success_goodsmvt
&----
text
----
FORM f_display_success_goodsmvt.
DESCRIBE TABLE i_success LINES v_line2.
WRITE:/ text-010, 35 text-011, 60 text-012 ,75 text-013, 100 text-014.
LOOP AT i_success INTO wa_success.
WRITE:/ wa_success-mat_doc, 35 wa_success-doc_year, 60 wa_success-plant, 75 wa_success-stge_loc, 100 wa_success-recordno.
ENDLOOP.
FREE: i_success.
ENDFORM. "f_display_success_goodsmvt
&----
*& Form f_populate_goodsmvt_item
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_populate_goodsmvt_item .
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = wa_goodsmvt-material
IMPORTING
output = wa_goodsmvt-material.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = wa_goodsmvt-entry_uom
IMPORTING
output = wa_goodsmvt-entry_uom.
wa_goodsmvt_item-material = wa_goodsmvt-material.
wa_goodsmvt_item-entry_uom = wa_goodsmvt-entry_uom.
wa_goodsmvt_item-plant = wa_goodsmvt-plant.
wa_goodsmvt_item-stge_loc = wa_goodsmvt-stge_loc.
wa_goodsmvt_item-move_type = wa_goodsmvt-move_type.
wa_goodsmvt_item-entry_qnt = wa_goodsmvt-entry_qnt.
wa_goodsmvt_item-val_type = wa_goodsmvt-val_type.
wa_goodsmvt_item-ean_upc = wa_goodsmvt-ean_upc. "SIR847
APPEND wa_goodsmvt_item TO i_goodsmvt_item .
ENDFORM. "f_populate_goodsmvt_item
&----
*& Form f_populate_goodsmvt_serialnumber
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_populate_goodsmvt_serialno.
wa_goodsmvt_serialnumber-serialno = wa_goodsmvt-serialno.
APPEND wa_goodsmvt_serialnumber TO i_goodsmvt_serialnumber.
ENDFORM. "f_populate_goodsmvt_serialno.
&----
*& Form f_populate_error_multiple
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_populate_error_multiple .
wa_error-plant = wa_goodsmvt_item-plant. "The Error records are put in an error internal table.
wa_error-stge_loc = wa_goodsmvt_item-stge_loc.
wa_error-err_desc = wa_return-message.
wa_error-err_msgtype = wa_return-type.
wa_error-err_msgnum = wa_return-number.
APPEND wa_error TO i_error.
ENDFORM. " f_populate_error
&----
*& Form f_populate_error_single
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_populate_error_single .
wa_error-material = wa_goodsmvt_item-material.
wa_error-serialno = wa_goodsmvt_serialnumber-serialno.
wa_error-entry_uom = wa_goodsmvt_item-entry_uom.
wa_error-plant = wa_goodsmvt_item-plant. "The Error records are put in an error internal table.
wa_error-stge_loc = wa_goodsmvt_item-stge_loc.
wa_error-move_type = wa_goodsmvt_item-move_type.
wa_error-entry_qnt = wa_goodsmvt_item-entry_qnt.
wa_error-val_type = wa_goodsmvt_item-val_type.
wa_error-err_desc = wa_return-message.
wa_error-err_msgtype = wa_return-type.
wa_error-err_msgnum = wa_return-number.
APPEND wa_error TO i_error.
ENDFORM. " f_populate_error_single
&----
*& Form f_populate_success
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_populate_success .
wa_success-mat_doc = wa_goodsmvt_headret-mat_doc.
wa_success-doc_year = wa_goodsmvt_headret-doc_year.
wa_success-material = wa_goodsmvt-material. "The success records are put in an success internal table.
wa_success-serialno = wa_goodsmvt-serialno.
wa_success-entry_uom = wa_goodsmvt-entry_uom.
wa_success-plant = wa_goodsmvt-plant.
wa_success-stge_loc = wa_goodsmvt-stge_loc.
wa_success-move_type = wa_goodsmvt-move_type.
wa_success-entry_qnt = wa_goodsmvt-entry_qnt.
wa_success-val_type = wa_goodsmvt-val_type.
wa_success-recordno = v_count.
APPEND wa_success TO i_success.
CLEAR wa_success.
ENDFORM. " f_populate_success