2009 Jan 07 12:59 AM
Hi experts,
The following code clears the "Delivery Complete" flag on a list of Purchase Orders uploaded from a CSV file.
The PO number is 9 digits long, however, in EKPO table it is stored as 10 digits (prefixed with a zero). The BAPI does not recognise the document number unless it is prefixed with a zero in the CSV file (which adds extra work for the user to create custom format in Excel to add the leading zero).
What code is required for the BAPI to recognise the 9 digit number without the leading zero? Perhaps the leading zero could be hard-coded into the program?
Any advice is much appreciated. Thanks for your time.
REPORT Z_MASS_REMOVE_FDI_DCI_BAPI.
*Check if file exists
DATA: rc TYPE sy-ucomm.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = 'X:\STO.TXT'
IMPORTING
return = rc.
IF rc EQ 0.
WRITE: / 'File does not exist'.
ENDIF.
TYPES: BEGIN OF ty_tab,
DOCNO(10),
ITEM(4),
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab,
wa_tab TYPE ty_tab.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'X:\STO.TXT'
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = it_tab
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.
END-OF-SELECTION.
LOOP AT it_tab INTO wa_tab.
WRITE:/ 'DOCUMENT: ',
wa_tab-DOCNO,
' ITEM: ',
wa_tab-ITEM.
WRITE: / '-----------------------------------------------------------------------'.
DATA: s_header TYPE bapimepoheader,
s_headerx TYPE bapimepoheaderx,
s_item TYPE bapimepoitem,
s_itemx TYPE bapimepoitemx,
i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
s_bapimepoheader TYPE bapimepoheader,
s_bapimepoheaderx TYPE bapimepoheaderx,
s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,
s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,
wa_message TYPE c LENGTH 100.
s_bapimepoheaderx-po_number = wa_tab-DOCNO.
s_bapimepoheader-po_number = wa_tab-DOCNO.
s_bapimepoitemx-PO_ITEM = wa_tab-ITEM.
s_bapimepoitem-PO_ITEM = wa_tab-ITEM.
*Remove Delivery Complete Indicator (DCI)
s_bapimepoitemx-NO_MORE_GR = 'X'.
s_bapimepoitem-NO_MORE_GR = ' '.
append s_bapimepoitem.
clear s_bapimepoitem.
append s_bapimepoitemx.
clear s_bapimepoitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = wa_tab-DOCNO
TABLES
return = i_return
poitem = s_bapimepoitem
poitemx = s_bapimepoitemx.
*Message types: S Success, E Error, W Warning, I Info, A Abort
*Supress all Warning Messages
DELETE i_return WHERE ( TYPE EQ 'W' ).
*Commit only if no errors have been returned
read table i_return with key type = 'E'.
if sy-subrc ne 0.
COMMIT WORK AND WAIT.
endif.
*Display Return Messages on Screen
LOOP AT i_return.
WRITE: / 'RETURN MESSAGE: ',
'ID: ',
i_return-id,
' TYPE: ',
i_return-type,
' NUMBER: ',
i_return-number,
' ',
i_return-message.
ENDLOOP.
WRITE: / '-----------------------------------------------------------------------'.
refresh : s_bapimepoitem,s_bapimepoitemx.
ENDLOOP.
Hi experts,
The following code clears the "Delivery Complete" flag on a list of Purchase Orders uploaded from a CSV file.
The PO number is 9 digits long, however, in EKPO table it is stored as 10 digits (prefixed with a zero). The BAPI does not recognise the document number unless it is prefixed with a zero in the CSV file (which adds extra work for the user to create custom format in Excel to add the leading zero).
What code is required for the BAPI to recognise the 9 digit number without the leading zero? Perhaps the leading zero could be hard-coded into the program?
Any advice is much appreciated. Thanks for your time.
REPORT Z_MASS_REMOVE_FDI_DCI_BAPI.
*Check if file exists
DATA: rc TYPE sy-ucomm.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = 'X:\STO.TXT'
IMPORTING
return = rc.
IF rc EQ 0.
WRITE: / 'File does not exist'.
ENDIF.
TYPES: BEGIN OF ty_tab,
DOCNO(10),
ITEM(4),
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab,
wa_tab TYPE ty_tab.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'X:\STO.TXT'
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = it_tab
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.
END-OF-SELECTION.
LOOP AT it_tab INTO wa_tab.
WRITE:/ 'DOCUMENT: ',
wa_tab-DOCNO,
' ITEM: ',
wa_tab-ITEM.
WRITE: / '-----------------------------------------------------------------------'.
DATA: s_header TYPE bapimepoheader,
s_headerx TYPE bapimepoheaderx,
s_item TYPE bapimepoitem,
s_itemx TYPE bapimepoitemx,
i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
s_bapimepoheader TYPE bapimepoheader,
s_bapimepoheaderx TYPE bapimepoheaderx,
s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,
s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,
wa_message TYPE c LENGTH 100.
s_bapimepoheaderx-po_number = wa_tab-DOCNO.
s_bapimepoheader-po_number = wa_tab-DOCNO.
s_bapimepoitemx-PO_ITEM = wa_tab-ITEM.
s_bapimepoitem-PO_ITEM = wa_tab-ITEM.
*Remove Delivery Complete Indicator (DCI)
s_bapimepoitemx-NO_MORE_GR = 'X'.
s_bapimepoitem-NO_MORE_GR = ' '.
append s_bapimepoitem.
clear s_bapimepoitem.
append s_bapimepoitemx.
clear s_bapimepoitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = wa_tab-DOCNO
TABLES
return = i_return
poitem = s_bapimepoitem
poitemx = s_bapimepoitemx.
*Message types: S Success, E Error, W Warning, I Info, A Abort
*Supress all Warning Messages
DELETE i_return WHERE ( TYPE EQ 'W' ).
*Commit only if no errors have been returned
read table i_return with key type = 'E'.
if sy-subrc ne 0.
COMMIT WORK AND WAIT.
endif.
*Display Return Messages on Screen
LOOP AT i_return.
WRITE: / 'RETURN MESSAGE: ',
'ID: ',
i_return-id,
' TYPE: ',
i_return-type,
' NUMBER: ',
i_return-number,
' ',
i_return-message.
ENDLOOP.
WRITE: / '-----------------------------------------------------------------------'.
refresh : s_bapimepoitem,s_bapimepoitemx.
ENDLOOP.
2009 Jan 07 1:41 AM
hi,
Use the conversion exit to make it as 10 digit char CONVERSION_EXIT_ALPHA_INPUT.
2009 Jan 07 1:44 AM
hi,
use these conversion exits
CONVERSION_EXIT_ALPHA_INPUT
CONVERSION_EXIT_ALPHA_OUTPUT
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |