<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic BAPI_PO_CHANGE document number leading zero problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982522#M1160893</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code clears the "Delivery Complete" flag on a list of Purchase Orders uploaded from a CSV file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice is much appreciated.  Thanks for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Jan 2009 00:59:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-07T00:59:04Z</dc:date>
    <item>
      <title>BAPI_PO_CHANGE document number leading zero problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982522#M1160893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code clears the "Delivery Complete" flag on a list of Purchase Orders uploaded from a CSV file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice is much appreciated.  Thanks for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2009 00:59:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982522#M1160893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-07T00:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_PO_CHANGE document number leading zero problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982523#M1160894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the conversion exit to make it as 10 digit char CONVERSION_EXIT_ALPHA_INPUT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2009 01:41:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982523#M1160894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-07T01:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_PO_CHANGE document number leading zero problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982524#M1160895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;use these conversion exits &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CONVERSION_EXIT_ALPHA_INPUT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CONVERSION_EXIT_ALPHA_OUTPUT&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2009 01:44:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-po-change-document-number-leading-zero-problem/m-p/4982524#M1160895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-07T01:44:22Z</dc:date>
    </item>
  </channel>
</rss>

