22 Replies Latest reply: Dec 13, 2006 9:18 AM by Eswar Rao Boddeti RSS

Error in PO using  BAPI

Deesanth Kumar
Currently Being Moderated

Hi,

 

   Hi i created upload prog for PO using BAPI_PO_CREATE1.I got the below error.so what will be problem whether the error is in the code are in the template.pls solve my issue.

 

the error is as below.

Creation of PO using Enjoy BAPI unsuccessful

 

Thanks,

Rajendra.

  • Re: Error in PO using  BAPI
    Eswar Rao Boddeti
    Currently Being Moderated

    Please let us know all other messages in the <b>RETURN</b> table...

     

    Kind Regards

    Eswar

    • Re: Error in PO using  BAPI
      Deesanth Kumar
      Currently Being Moderated

      Hi Eswar,

       

         i am getting only that message and i used the below code for the message,

       

      LOOP AT DATA_TAB.

          READ TABLE RETURN WITH KEY MESSAGE = RETURN-MESSAGE.

          MOVE-CORRESPONDING RETURN    TO I_RETURN.

          MOVE-CORRESPONDING DATA_TAB  TO I_RETURN.

          APPEND I_RETURN.

          CLEAR  I_RETURN.

        ENDLOOP.

       

      Thanks,

      Rajendra.

      • Re: Error in PO using  BAPI
        Eswar Rao Boddeti
        Currently Being Moderated

        Hi Rajendra

         

        I guess you are not handling of all the messages in Internal Table RETURN...

         

        Place a break point after calling the FM: BAPI_PO_CREATE1 and check the values in the RETURN internal table...

         

        Kind Regards

        Eswar

        • Re: Error in PO using  BAPI
          Deesanth Kumar
          Currently Being Moderated

          Hi Eswar,

           

             i am getting the below messages in the RETURN.

          W   |ME                  |658   |Please also populate interface parameter <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |W5                  |152   |Compulsory fields missing                <

          E   |ME                  |013   |Document type ZME not allowed with doc.  <

          I   |                    |000   |Creation of PO using Enjoy BAPI unsuccess<

          E   |MEPO                |002   |PO header data still faulty              <

          E   |MEPO                |071   |Item 00010 does not exist                <

          E   |ME                  |013   |Document type ZME not allowed with doc.  <

           

              SO is there any problem in the template which i have the date is wrong or in the code.pls help me to solve the issue.

           

          Thanks,

          Rajendra.

          • Re: Error in PO using  BAPI
            Eswar Rao Boddeti
            Currently Being Moderated

            HI Rajendra

             

            Can you post your code???

             

            Kind Regards

            Eswar

            • Re: Error in PO using  BAPI
              Deesanth Kumar
              Currently Being Moderated

              Hi Eswar,

               

                   Below is the code,

               

              tables: T100.

              DATA : POHEADER         LIKE BAPIMEPOHEADER   OCCURS 0 WITH HEADER LINE,

                     POHEADERX        LIKE BAPIMEPOHEADERX  OCCURS 0 WITH HEADER LINE,

                     POITEM           LIKE BAPIMEPOITEM     OCCURS 0 WITH HEADER LINE,

                     POITEMX          LIKE BAPIMEPOITEMX    OCCURS 0 WITH HEADER LINE,

                     POSCHEDULE       LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,

                     POSCHEDULEX      LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE,

                     POACCOUNT        LIKE BAPIMEPOACCOUNT  OCCURS 0 WITH HEADER LINE,

                     POACCOUNTX       LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE,

                     POCOND           LIKE BAPIMEPOCOND     OCCURS 0 WITH HEADER LINE,

                     POCONDX          LIKE BAPIMEPOCONDX    OCCURS 0 WITH HEADER LINE,

                     RETURN           LIKE BAPIRET2         OCCURS 0 WITH HEADER LINE,

                     EXPPURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.

                     POHEADER-COMP_CODE = '2006'.

               

              DATA : BEGIN OF DATA_TAB OCCURS 0,

                         BSART(40) TYPE C,

                         LIFNR(10) TYPE C,

                         EKORG(4)  TYPE C,

                         EKGRP(3)  TYPE C,

                         EBELP(5)  TYPE C,

                         MATNR(18) TYPE C,

                         MAKTX(40) TYPE C,

                         WERKS(4)  TYPE C,

                         CHARG(10) TYPE C,

                         BEDNR(10) TYPE C,

                         PSTYP(1)  TYPE C,

                         KNTTP(1)  TYPE C,

                         ANLN1(12) TYPE C,

                         ANLN2(4)  TYPE C,

                         AUFNR(12) TYPE C,

                         PS_PSP_PNR(8) TYPE C,

                         EINDT(8)  TYPE C,

                         WAERS(5)  TYPE C,

                         NETPR(11) TYPE C,

                         WKURS(9)  TYPE C,

                         BEDAT(8)  TYPE C,

                         SAKTO(10) TYPE C,

                         KOSTL(10) TYPE C,

                         MENGE(13) TYPE C,

                         MEINS(3)  TYPE C,

                      END OF DATA_TAB.

               

              *DATA : BEGIN OF DATA_TAB OCCURS 0,

              •           BSART LIKE EKKO-BSART,

              •           LIFNR LIKE EKKO-LIFNR,

              •           EKORG LIKE EKKO-EKORG,

              •           EKGRP LIKE EKKO-EKGRP,

              •           EBELP LIKE EKPO-EBELP,

              •           MATNR LIKE EKPO-MATNR,

              •           MAKTX LIKE MAKT-MAKTX,

              •           WERKS LIKE EKPO-WERKS,

              •           CHARG LIKE MCH1-CHARG,

              •           BEDNR LIKE EKPO-BEDNR,

              •           PSTYP LIKE EKPO-PSTYP,

              •           KNTTP LIKE EKPO-KNTTP,

              •           ANLN1 LIKE EKKN-ANLN1,

              •           ANLN2 LIKE EKKN-ANLN2,

              •           AUFNR LIKE EKKN-AUFNR,

              •           PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,

              •           EINDT LIKE EKET-EINDT,

              •           WAERS LIKE EKKO-WAERS,

              •           NETPR LIKE EKPO-NETPR,

              •           WKURS LIKE EKKO-WKURS,

              •           BEDAT LIKE EKKO-BEDAT,

              •           SAKTO LIKE EKKN-SAKTO,

              •           KOSTL LIKE EKKN-KOSTL,

              •           MENGE LIKE EKPO-MENGE,

              •           MEINS LIKE EKPO-MEINS,

              •        END OF DATA_TAB.

               

               

              ************************************************************************

              • Data

              ************************************************************************

              DATA : wc_file    type string,

                     wc_tabix   like sy-tabix,

                     wc_fl(40)  type c,

                     wc_tot(19) type n.

               

              data: i_tab1        like alsmex_tabline occurs 0 with header line,

              •      w_Data_tab    like Data_tab occurs 0 with header line,

                    w_Data_tab    like Data_tab,

                    w_totlines    type i,

                    w_end_col     type i.

               

              DATA : C_X(1) TYPE c VALUE 'X'.

              DATA : W_ERRSTAT(18)   TYPE C.

              DATA : W_ERRMSG(18)    TYPE C.

              DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.

              DATA : BEGIN OF I_RETURN OCCURS 0.

                      INCLUDE STRUCTURE DATA_TAB.

              DATA : EBELN   LIKE I_EKKO-EBELN.

              DATA : MESSAGE LIKE RETURN-MESSAGE.

              DATA : END OF I_RETURN.

               

              ************************************************************************

              • ALV

              ************************************************************************

              type-pools: slis.

              data: txt_report          like dokhl-object. "Reportname für Erläuterungsaufruf

              data: gt_fieldcat         type slis_t_fieldcat_alv,

                    gt_events           type slis_t_event,

                    gt_sort             type slis_t_sortinfo_alv,

                    gt_list_top_of_page type slis_t_listheader,

                    gs_layout           type slis_layout_alv.

               

              ************************************************************************

              *Parameters

              ************************************************************************

              selection-screen begin of block mysel1 with frame.

               

              parameters: pc_file like rlgrap-filename.  " obligatory default 'C:'." default 'C:mat.xls'.

               

              selection-screen end of block mysel1.

               

              ************************************************************************

              *AT SELECTION-SCREEN

              ************************************************************************

              at selection-screen on pc_file.

               

              call function 'WS_QUERY'

                     exporting

                          query    = 'FL'

                          filename = pc_file

                     importing

                          return   = wc_fl.

                     condense wc_fl no-gaps.

               

                  if wc_fl eq space.

              •       message e009 raising pc_file.

                     exit.

                  endif.

               

              at selection-screen on value-request for pc_file.

               

                             wc_file = pc_file.

               

              call function 'WS_FILENAME_GET'

                   exporting

                         mask        = ' '

                         title       = text-001

                  importing

                         filename    = pc_file

                  exceptions

                    inv_winsys       = 1

                    no_batch         = 2

                    selection_cancel = 3

                    selection_error  = 4

                    others           = 5.

               

               

              ************************************************************************

              • SELECTION-SCREEN

              ************************************************************************

              start-of-selection.

                        perform 1000_getfile.

                        perform 2000_process_bapi.

                        perform fieldcat_init  using gt_fieldcat[].

                        perform layout_init    using gs_layout.

                        perform comment_build  using gt_list_top_of_page[].

                        perform eventtab_build using gt_events[].

                        PERFORM sort_build     USING gt_sort[].

                        perform 3000_updation_log.

                 end-of-selection.

               

              *&----


              *

              *&      Form  1000_getfile

              *&----


              *

              •       text

              *----


              *

              • -->  p1        text

              • <--  p2        text

              *----


              *

              FORM 1000_getfile .

               

              *w_data_tab = data_tab.

               

              • Get the No of Rows in the file

                                CALL FUNCTION 'AA_FILE_UPLOAD_EXCEL'

                                  EXPORTING

                                    I_FILENAME                 = pc_file

              •                     I_TEST                     =

              •                     I_UCOMM                    =

              •                     I_MAXCOLS                  =

                                   I_DELIMITER                = ','

                                  TABLES

                                    ET_FILECONTENT             = DATA_TAB

                                 EXCEPTIONS

                                   ERROR_ACCESSING_FILE       = 1

                                   OTHERS                     = 2

                                          .

                                IF SY-SUBRC <> 0.

                                   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

                                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

                                ENDIF.

              *

              *

              • call function 'FAA_FILE_UPLOAD_EXCEL'

              •     exporting

              •         i_filename           = pc_file

              •         i_delimiter          = ','

              •     tables

              •         et_filecontent       = DATA_TAB

              •     exceptions

              •         error_accessing_file = 1

              •         others               = 2.

               

              •     if sy-subrc <> 0.

              •            message id sy-msgid type sy-msgty number sy-msgno

              •            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

              •     endif.

               

                   describe table Data_tab lines w_totlines.

                   w_end_col = 25.

              •     w_totlines = 1.

               

              • Upload the data from file to Internal Table

               

                   refresh Data_tab.

               

                 call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

                       exporting

                            filename    = pc_file

                            i_begin_col = 1 " Starting col on each row from the upload excel file

                            i_begin_row = 4 " Starting row from the upload excel file

                            i_end_col   = w_end_col " No. of columns in the upload excel file

                            i_end_row   = w_totlines " Possible no. of rows in the upload excel file

                       tables

                             intern     = i_tab1

                       exceptions

                             inconsistent_parameters = 1

                             upload_ole              = 2

                             others                  = 3.

               

              •         if sy-subrc <> 0.

              •              message id sy-msgid type sy-msgty number sy-msgno

              •              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

              •         endif.

               

                  sort i_tab1 by row col.

                  loop at i_tab1.

                     case i_tab1-col.

                    when 1.

                       clear w_Data_tab.

                        move i_tab1-value to w_Data_tab-bsart.

                    when 2.

                        move i_tab1-value to w_Data_tab-lifnr.

                    when 3.

                        move i_tab1-value to w_Data_tab-ekorg.

                    when 4.

                        move i_tab1-value to w_Data_tab-ekgrp.

                    when 5.

                        move i_tab1-value to w_Data_tab-ebelp.

                    when 6.

                        move i_tab1-value to w_Data_tab-matnr.

                    when 7.

                        move i_tab1-value to w_Data_tab-maktx.

                    when 8.

                        move i_tab1-value to w_Data_tab-werks.

                    when 9.

                        move i_tab1-value to w_Data_tab-charg.

                    when 10.

                        move i_tab1-value to w_Data_tab-bednr.

                    when 11.

                        move i_tab1-value to w_Data_tab-pstyp.

                    when 12.

                        move i_tab1-value to w_Data_tab-knttp.

                    when 13.

                        move i_tab1-value to w_Data_tab-anln1.

                    when 14.

                        move i_tab1-value to w_Data_tab-anln2.

                    when 15.

                        move i_tab1-value to w_Data_tab-aufnr.

                    when 16.

                        move i_tab1-value to w_Data_tab-ps_psp_pnr.

                    when 17.

                        move i_tab1-value to w_Data_tab-eindt.

                    when 18.

                        move i_tab1-value to w_Data_tab-waers.

                    when 19.

                        move i_tab1-value to w_Data_tab-netpr.

                    when 20.

                        move i_tab1-value to w_Data_tab-wkurs.

                    when 21.

                        move i_tab1-value to w_Data_tab-bedat.

                    when 22.

                        move i_tab1-value to w_Data_tab-sakto.

                    when 23.

                        move i_tab1-value to w_Data_tab-kostl.

                    when 24.

                        move i_tab1-value to w_Data_tab-menge.

                    when 25.

                        move i_tab1-value to w_Data_tab-meins.

               

                   endcase.

               

                      at end of row.

                        append w_Data_tab to Data_tab.

                        clear  w_Data_tab.

                       endat.

               

                  endloop.

                        clear wc_tot.

                        describe table Data_tab lines wc_tot.

               

              ENDFORM.                                      " 1000_getfile

              *&----


              *

              *&      Form  2000_process_bapi

              *&----


              *

              •       text

              *----


              *

              • -->  p1        text

              • <--  p2        text

              *----


              *

              FORM 2000_process_bapi .

               

              LOOP AT DATA_TAB.

               

                POHEADER-DOC_TYPE   = DATA_TAB-BSART.

                POHEADER-VENDOR     = DATA_TAB-LIFNR.

                POHEADER-PURCH_ORG  = DATA_TAB-EKORG.

                POHEADER-PUR_GROUP  = DATA_TAB-EKGRP.

                POHEADER-DOC_DATE   = DATA_TAB-BEDAT.

              APPEND POHEADER.

               

                POHEADERX-DOC_TYPE   = 'X'.

                POHEADERX-VENDOR     = 'X'.

                POHEADERX-PURCH_ORG  = 'X'.

                POHEADERX-PUR_GROUP  = 'X'.

                POHEADERX-DOC_DATE   = 'X'.

              APPEND POHEADERX.

               

                POITEM-PO_ITEM        = DATA_TAB-EBELP.

                POITEM-MATERIAL       = DATA_TAB-MATNR.

                POITEM-SHORT_TEXT     = DATA_TAB-MAKTX.

                POITEM-PLANT          = DATA_TAB-WERKS.

                POITEM-BATCH          = DATA_TAB-CHARG.

                POITEM-TRACKINGNO     = DATA_TAB-BEDNR.

                POITEM-ITEM_CAT       = DATA_TAB-PSTYP.

                POITEM-ACCTASSCAT     = DATA_TAB-KNTTP.

                POITEM-NET_PRICE      = DATA_TAB-NETPR.

                POITEM-QUANTITY       = DATA_TAB-MENGE.

                POITEM-PO_UNIT        = DATA_TAB-MEINS.

              APPEND POITEM.

               

                POITEMX-PO_ITEM        = 'X'.

                POITEMX-MATERIAL       = 'X'.

                POITEMX-SHORT_TEXT     = 'X'.

                POITEMX-PLANT          = 'X'.

                POITEMX-BATCH          = 'X'.

                POITEMX-TRACKINGNO     = 'X'.

                POITEMX-ITEM_CAT       = 'X'.

                POITEMX-ACCTASSCAT     = 'X'.

                POITEMX-NET_PRICE      = 'X'.

                POITEMX-QUANTITY       = 'X'.

                POITEMX-PO_UNIT        = 'X'.

              APPEND POITEMX.

               

                POACCOUNT-ASSET_NO     = DATA_TAB-ANLN1.

                POACCOUNT-SUB_NUMBER   = DATA_TAB-ANLN2.

                POACCOUNT-ORDERID      = DATA_TAB-AUFNR.

                POACCOUNT-WBS_ELEMENT  = DATA_TAB-PS_PSP_PNR.

                POACCOUNT-GL_ACCOUNT   = DATA_TAB-SAKTO.

                POACCOUNT-COSTCENTER   = DATA_TAB-KOSTL.

              APPEND POACCOUNT.

               

               

                POACCOUNTX-ASSET_NO    = 'X'.

                POACCOUNTX-SUB_NUMBER  = 'X'.

                POACCOUNTX-ORDERID     = 'X'.

                POACCOUNTX-WBS_ELEMENT = 'X'.

                POACCOUNTX-GL_ACCOUNT  = 'X'.

                POACCOUNTX-COSTCENTER  = 'X'.

              APPEND POACCOUNTX.

               

               

                POCOND-CURRENCY        = DATA_TAB-WAERS.

                POCOND-CONEXCHRAT      = DATA_TAB-WKURS.

              APPEND POCOND.

               

                POCONDX-CURRENCY       = 'X'.

                POCONDX-CONEXCHRAT     = 'X'.

              APPEND POCONDX.

               

                POSCHEDULE-PO_ITEM        = DATA_TAB-EBELP.

                POSCHEDULE-DELIVERY_DATE  = DATA_TAB-EINDT.

              APPEND POSCHEDULE.

               

                POSCHEDULEX-PO_ITEM        = 'X'.

                POSCHEDULEX-DELIVERY_DATE  = 'X'.

              APPEND POSCHEDULEX.

               

              ENDLOOP.

               

              CALL FUNCTION 'BAPI_PO_CREATE1'

                EXPORTING

                  POHEADER                     = POHEADER

                  POHEADERX                    = POHEADERX

              •   POADDRVENDOR                 =

              •   TESTRUN                      =

              •   MEMORY_UNCOMPLETE            =

              •   MEMORY_COMPLETE              =

              •   POEXPIMPHEADER               =

              •   POEXPIMPHEADERX              =

              •   VERSIONS                     =

              •   NO_MESSAGING                 =

              •   NO_MESSAGE_REQ               =

              •   NO_AUTHORITY                 =

              •   NO_PRICE_FROM_PO             =

              IMPORTING

                  EXPPURCHASEORDER             = EXPPURCHASEORDER

              •   EXPHEADER                    =

              •   EXPPOEXPIMPHEADER            =

              TABLES

                  RETURN                       = RETURN

                  POITEM                       = POITEM

                  POITEMX                      = POITEMX

              •   POADDRDELIVERY               =

                  POSCHEDULE                   = POSCHEDULE

                  POSCHEDULEX                  = POSCHEDULEX

                  POACCOUNT                    = POACCOUNT

              •   POACCOUNTPROFITSEGMENT       =

                  POACCOUNTX                   = POACCOUNTX

              •   POCONDHEADER                 =

              •   POCONDHEADERX                =

                  POCOND                       = POCOND

                  POCONDX                      = POCONDX

              •   POLIMITS                     =

              •   POCONTRACTLIMITS             =

              •   POSERVICES                   =

              •   POSRVACCESSVALUES            =

              •   POSERVICESTEXT               =

              •   EXTENSIONIN                  =

              •   EXTENSIONOUT                 =

              •   POEXPIMPITEM                 =

              •   POEXPIMPITEMX                =

              •   POTEXTHEADER                 =

              •   POTEXTITEM                   =

              •   ALLVERSIONS                  =

              •   POPARTNER                    =

                        .

               

              IF SY-SUBRC = 0.

              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

              EXPORTING

                 WAIT          = C_X

              • IMPORTING

              •   RETURN        =

              .

              ENDIF.

               

                LOOP AT DATA_TAB.

               

               

                  READ TABLE RETURN WITH KEY MESSAGE = RETURN-MESSAGE.

               

                  MOVE-CORRESPONDING RETURN    TO I_RETURN.

                  MOVE-CORRESPONDING DATA_TAB  TO I_RETURN.

               

                  APPEND I_RETURN.

                  CLEAR  I_RETURN.

               

                ENDLOOP.

               

                                •   TO GET THE PO NUMBER     *************

                 SELECT EBELN BSART FROM EKKO INTO TABLE I_EKKO

                                    WHERE BSART EQ DATA_TAB-BSART

                                      AND LIFNR EQ DATA_TAB-LIFNR

                                      AND EKORG EQ DATA_TAB-EKORG

                                      AND EKGRP EQ DATA_TAB-EKGRP.

               

                  LOOP AT I_EKKO.

               

                     MOVE I_EKKO-EBELN TO I_RETURN-EBELN.

               

                    APPEND I_RETURN.

                    CLEAR  I_RETURN.

                  ENDLOOP.

               

              *

              *ALM_ME_MAP_RETURN_MESSAGE

                       .

              •      IF RETURN IS INITIAL.

              •          W_ERRSTAT      = 'PASS'.

              •       ELSE.

              •          W_ERRSTAT      = 'FAIL'.

              •          LOOP AT RETURN.

              •             W_ERRMSG    = RETURN-MESSAGE.

              •           ENDLOOP.

              •       ENDIF.

              •      WAIT UP TO 2 SECONDS.

              *

              • ENDIF.

              *

              • LOOP AT RETURN.

              *

              •    WRITE : / RETURN-TYPE, RETURN-ID, RETURN-NUMBER, RETURN-MESSAGE,

              •              RETURN-LOG_NO, RETURN-LOG_MSG_NO, RETURN-MESSAGE_V1,

              •              RETURN-MESSAGE_V2, RETURN-MESSAGE_V3, RETURN-MESSAGE_V4,

              •              RETURN-PARAMETER, RETURN-ROW, RETURN-FIELD, RETURN-SYSTEM.

              *

              • ENDLOOP.

               

                ENDFORM.                                     " 2000_process_bapi

              *&----


              *

              *&      Form  fieldcat_init

              *&----


              *

              •       text

              *----


              *

              •      -->P_GT_FIELDCAT[]  text

              *----


              *

              FORM fieldcat_init  USING lt_fieldcat type slis_t_fieldcat_alv.

                  data: ls_fieldcat type slis_fieldcat_alv.

               

              clear ls_fieldcat.

              ls_fieldcat-fieldname     = 'EBELN'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-001.

              ls_fieldcat-seltext_m     = text-001.

              ls_fieldcat-seltext_s     = text-001.

              ls_fieldcat-reptext_ddic  = text-001.

              ls_fieldcat-outputlen     = '10'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              clear ls_fieldcat.

              ls_fieldcat-fieldname     = 'WERKS'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-002.

              ls_fieldcat-seltext_m     = text-002.

              ls_fieldcat-seltext_s     = text-002.

              ls_fieldcat-reptext_ddic  = text-002.

              ls_fieldcat-outputlen     = '4'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              ls_fieldcat-fieldname     = 'KNTTP'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-003.

              ls_fieldcat-seltext_m     = text-003.

              ls_fieldcat-seltext_s     = text-003.

              ls_fieldcat-reptext_ddic  = text-003.

              ls_fieldcat-outputlen     = '4'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              clear ls_fieldcat.

              ls_fieldcat-fieldname     = 'MATNR'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-004.

              ls_fieldcat-seltext_m     = text-004.

              ls_fieldcat-seltext_s     = text-004.

              ls_fieldcat-reptext_ddic  = text-004.

              ls_fieldcat-outputlen     = '18'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              ls_fieldcat-fieldname     = 'MENGE'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-005.

              ls_fieldcat-seltext_m     = text-005.

              ls_fieldcat-seltext_s     = text-005.

              ls_fieldcat-reptext_ddic  = text-005.

              ls_fieldcat-outputlen     = '10'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              clear ls_fieldcat.

              ls_fieldcat-fieldname     = 'NETPR'.

              ls_fieldcat-datatype      = 'CURR'.

              ls_fieldcat-seltext_l     = text-006.

              ls_fieldcat-seltext_m     = text-006.

              ls_fieldcat-seltext_s     = text-006.

              ls_fieldcat-reptext_ddic  = text-006.

              ls_fieldcat-outputlen     = '11'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

              ls_fieldcat-fieldname     = 'MESSAGE'.

              ls_fieldcat-datatype      = 'C'.

              ls_fieldcat-seltext_l     = text-007.

              ls_fieldcat-seltext_m     = text-007.

              ls_fieldcat-seltext_s     = text-007.

              ls_fieldcat-reptext_ddic  = text-007.

              ls_fieldcat-outputlen     = '50'.

              append ls_fieldcat to lt_fieldcat.

              clear ls_fieldcat.

               

               

              ENDFORM.                                       " fieldcat_init

              *&----


              *

              *&      Form  layout_init

              *&----


              *

              •       text

              *----


              *

              •      -->P_GS_LAYOUT  text

              *----


              *

              FORM layout_init  USING  ls_layout type slis_layout_alv.

               

                    ls_layout-zebra = 'X'.

               

              ENDFORM.                                          " layout_init

              *&----


              *

              *&      Form  comment_build

              *&----


              *

              •       text

              *----


              *

              •      -->P_GT_LIST_TOP_OF_PAGE[]  text

              *----


              *

              FORM comment_build  USING Lt_top_of_page type slis_t_listheader.

               

                field-symbols: .

                data: ls_line type slis_listheader.

                data: i_sel   like textpool occurs 0 with header line.

                      read  textpool sy-repid into i_sel language sy-langu.

                      delete i_sel where id ne 'S'.

               

                        •    LIST HEADING LINE: TYPE H

                  clear ls_line.

                    ls_line-typ    = 'H'.

                    ls_line-info   = text-020.

                  append ls_line to lt_top_of_page.

               

                  clear ls_line.

                    ls_line-typ    = 'S'.

                    ls_line-key    = text-021.

                  append ls_line to lt_top_of_page.

               

                      •    Selection-screen

                loop at i_sel.

                  assign (i_sel-key) to .

                  append ls_line to lt_top_of_page.

              endloop.

               

              ENDFORM.                                          " comment_build

              *&----


              *

              *&      Form  eventtab_build

              *&----


              *

              •       text

              *----


              *

              •      -->P_GT_EVENTS[]  text

              *----


              *

              FORM eventtab_build  USING lt_events type slis_t_event.

               

              data: ls_event type slis_alv_event.

                       move 'PF_STATUS_SET' to ls_event-name.

                       move 'Z2006RMMPOUPLOAD' to ls_event-form.

                    append ls_event to lt_events.

                  clear ls_event.

               

              ENDFORM.                                          "eventtab_build

               

              *----

              -


              • FORM PF_STATUS_SET

              *----

              -


              form Z2006RMMPOUPLOAD using extab type slis_t_extab. "#EC CALLED

               

                       set pf-status 'Z2006RMMPOUPLOAD'. "EXCLUDING extab.

               

              endform.                                          "Z2006RMMPOUPLOAD

               

              *----


              *

              • FORM TOP_OF_PAGE *

              *----


              *

              form top_of_page.

               

                   call function 'REUSE_ALV_COMMENTARY_WRITE'

                      exporting

                          i_logo             = 'MECOMB'

                          it_list_commentary = gt_list_top_of_page.

               

              endform.                                           "top_of_page

              *&----


              *

              *&      Form  3000_updation_log

              *&----


              *

              •       text

              *----


              *

              • -->  p1        text

              • <--  p2        text

              *----


              *

              FORM 3000_updation_log .

               

                             CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

                              EXPORTING

              •                  I_INTERFACE_CHECK                 = ' '

              •                  I_BYPASSING_BUFFER                = ' '

              •                  I_BUFFER_ACTIVE                   = ' '

                                 I_CALLBACK_PROGRAM                = 'Z2006RMMPOUPLOAD'

              •                  I_CALLBACK_PF_STATUS_SET          = ' '

              •                  I_CALLBACK_USER_COMMAND           = ' '

                                 I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'

              •                  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '

              •                  I_CALLBACK_HTML_END_OF_LIST       = ' '

              •                  I_STRUCTURE_NAME                  =

              •                  I_BACKGROUND_ID                   = ' '

              •                  I_GRID_TITLE                      =

              •                  I_GRID_SETTINGS                   =

                                 IS_LAYOUT                         = gs_layout

                                 IT_FIELDCAT                       = gt_fieldcat[]

              •                  IT_EXCLUDING                      =

              •                  IT_SPECIAL_GROUPS                 =

              •                  IT_SORT                           =

              •                  IT_FILTER                         =

              •                  IS_SEL_HIDE                       =

              •                  I_DEFAULT                         = 'X'

              •                  I_SAVE                            = ' '

              •                  IS_VARIANT                        =

                                 IT_EVENTS                         = gt_events[]

              •                  IT_EVENT_EXIT                     =

              •                  IS_PRINT                          =

              •                  IS_REPREP_ID                      =

              •                  I_SCREEN_START_COLUMN             = 0

              •                  I_SCREEN_START_LINE               = 0

              •                  I_SCREEN_END_COLUMN               = 0

              •                  I_SCREEN_END_LINE                 = 0

              •                  IT_ALV_GRAPHICS                   =

              •                  IT_HYPERLINK                      =

              •                  IT_ADD_FIELDCAT                   =

              •                  IT_EXCEPT_QINFO                   =

              •                  I_HTML_HEIGHT_TOP                 =

              •                  I_HTML_HEIGHT_END                 =

              •                IMPORTING

              •                  E_EXIT_CAUSED_BY_CALLER           =

              •                  ES_EXIT_CAUSED_BY_USER            =

                               TABLES

                                 T_OUTTAB                          = I_RETURN

                               EXCEPTIONS

                                 PROGRAM_ERROR                     = 1

                                 OTHERS                            = 2

                                       .

                             IF SY-SUBRC <> 0.

              •              MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

              •              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

                             ENDIF.

               

              ENDFORM.                                      " 3000_updation_log

              *&----


              *

              *&      Form  sort_build

              *&----


              *

              •       text

              *----


              *

              •      -->P_GT_SORT[]  text

              *----


              *

              FORM sort_build  USING lt_sort type slis_t_sortinfo_alv.

               

              data: ls_sort type slis_sortinfo_alv.

               

              ls_sort-fieldname = 'EBELN'.

              ls_sort-up = 'X'.

              ls_sort-subtot = 'X'.

              append ls_sort to lt_sort.

              clear ls_sort.

               

              ls_sort-fieldname = 'MATNR'.

              ls_sort-up = 'X'.

              append ls_sort to lt_sort.

              clear ls_sort.

               

              ENDFORM.                                          " sort_build

               

               

              Thanks,

              Regards,

              Rajendra

               

              • Re: Error in PO using  BAPI
                Eswar Rao Boddeti
                Currently Being Moderated

                Hi Rajendra

                 

                Please go through my findings below:

                1. I doubt on your file layout. Is it that everytime for your file you will receive details of only one PO???

                 

                I would advice you to for a separate column for identifying the records.

                 

                Eg:

                HA for Header

                IT for Items

                and etc.. depending on your criteria.

                 

                2. POHEADER and POHEADERX are structures for BAPI: BAPI_PO_CREATE1.

                So we have to populate only once.

                 

                3. Try to ignore passing unnecessary parameters.

                Eg: MAKTX, SAP can internally get the same from Material Master.

                 

                4. We have to pass the item number in Update Flags also.

                Eg: While we are adding item 000010

                The item number should be passed for POITEM, POITEMX, POSCHEDULE, POSCHEUDLEX, POCOND, POCONDX.

                 

                Hope this helps.

                 

                Kind Regards

                Eswar

                • Re: Error in PO using  BAPI
                  Deesanth Kumar
                  Currently Being Moderated

                  Hi Eswar,

                   

                      Still i am getting error and below is the message from RETURN

                   

                  E   |W5                   |005   |Please enter items first                 <

                  W   |ME                  |083   |Enter Document type                      <

                  I   |                          |000   |Creation of PO using Enjoy BAPI unsuccess<

                  E   |MEPO              |002   |PO header data still faulty              <

                  E   |ME                   |083   |Enter Order type   

                   

                  further i dont know what to change pls guide me to solve the issue.

                   

                  Thanks,

                  Rajendra.

                  • Re: Error in PO using  BAPI
                    Eswar Rao Boddeti
                    Currently Being Moderated

                    Hi Rajendra

                     

                    I guess you are still missing some data while passing to the BAPI. Please check in debugging the values that you are passing to the BAPI.

                     

                    Kind Regards

                    Eswar

                    • Re: Error in PO using  BAPI
                      Deesanth Kumar
                      Currently Being Moderated

                      Hi Eswar,

                       

                             Even if i change the value from the template the RETURN message error also varying.so is there problem in my template sample data or in my coding.if in coding i change as you told but still i could not solve the issue.pls help me to solve the issue.

                       

                      Thanks,

                      Rajendra

                      • Re: Error in PO using  BAPI
                        Eswar Rao Boddeti
                        Currently Being Moderated

                        HI

                         

                        Please try after making the changes as below:

                         

                        <b>

                        DATA : POHEADER LIKE BAPIMEPOHEADER, " OCCURS 0 WITH HEADER LINE,
                               POHEADERX LIKE BAPIMEPOHEADERX. " OCCURS 0 WITH HEADER LINE,

                        </b>

                         

                        LOOP AT DATA_TAB.
                        
                          POHEADER-DOC_TYPE = DATA_TAB-BSART.
                          POHEADER-VENDOR = DATA_TAB-LIFNR.
                          POHEADER-PURCH_ORG = DATA_TAB-EKORG.
                          POHEADER-PUR_GROUP = DATA_TAB-EKGRP.
                          POHEADER-DOC_DATE = DATA_TAB-BEDAT.
                        <b>*  APPEND POHEADER.</b>
                        
                          POHEADERX-DOC_TYPE = 'X'.
                          POHEADERX-VENDOR = 'X'.
                          POHEADERX-PURCH_ORG = 'X'.
                          POHEADERX-PUR_GROUP = 'X'.
                          POHEADERX-DOC_DATE = 'X'.
                        <b>*  APPEND POHEADERX.</b>
                        
                          POITEM-PO_ITEM = DATA_TAB-EBELP.
                          POITEM-MATERIAL = DATA_TAB-MATNR.
                        <b>*  POITEM-SHORT_TEXT = DATA_TAB-MAKTX.</b>
                          POITEM-PLANT = DATA_TAB-WERKS.
                        <b>*  POITEM-BATCH = DATA_TAB-CHARG.
                        *  POITEM-TRACKINGNO = DATA_TAB-BEDNR.
                        *  POITEM-ITEM_CAT = DATA_TAB-PSTYP.</b>
                          POITEM-ACCTASSCAT = DATA_TAB-KNTTP.
                          POITEM-NET_PRICE = DATA_TAB-NETPR.
                          POITEM-QUANTITY = DATA_TAB-MENGE.
                        <b>*  POITEM-PO_UNIT = DATA_TAB-MEINS.</b>
                          APPEND POITEM.
                        
                          POITEMX-PO_ITEM = 'X'.
                          POITEMX-MATERIAL = 'X'.
                        <b>*  POITEMX-SHORT_TEXT = 'X'.</b>
                          POITEMX-PLANT = 'X'.
                        <b>*  POITEMX-BATCH = 'X'.
                        *  POITEMX-TRACKINGNO = 'X'.
                        *  POITEMX-ITEM_CAT = 'X'.</b>
                          POITEMX-ACCTASSCAT = 'X'.
                          POITEMX-NET_PRICE = 'X'.
                          POITEMX-QUANTITY = 'X'.
                        <b>*  POITEMX-PO_UNIT = 'X'.</b>
                          APPEND POITEMX.
                        
                        <b>  POACCOUNT-PO_ITEM = DATA_TAB-EBELP.</b>
                          POACCOUNT-ASSET_NO = DATA_TAB-ANLN1.
                          POACCOUNT-SUB_NUMBER = DATA_TAB-ANLN2.
                          POACCOUNT-ORDERID = DATA_TAB-AUFNR.
                          POACCOUNT-WBS_ELEMENT = DATA_TAB-PS_PSP_PNR.
                          POACCOUNT-GL_ACCOUNT = DATA_TAB-SAKTO.
                          POACCOUNT-COSTCENTER = DATA_TAB-KOSTL.
                          APPEND POACCOUNT.
                        
                        
                        <b>  POACCOUNTX-PO_ITEM = DATA_TAB-EBELP.</b>
                          POACCOUNTX-ASSET_NO = 'X'.
                          POACCOUNTX-SUB_NUMBER = 'X'.
                          POACCOUNTX-ORDERID = 'X'.
                          POACCOUNTX-WBS_ELEMENT = 'X'.
                          POACCOUNTX-GL_ACCOUNT = 'X'.
                          POACCOUNTX-COSTCENTER = 'X'.
                          APPEND POACCOUNTX.
                        
                        
                        <b>  POCOND-ITM_NUMBER = DATA_TAB-EBELP.
                          POCOND-COND_VALUE = DATA_TAB-NETPR.</b> 
                          POCOND-CURRENCY = DATA_TAB-WAERS.
                        <b>*  POCOND-CONEXCHRAT = DATA_TAB-WKURS.</b>
                          APPEND POCOND.
                        
                        <b>  POCONDX-ITM_NUMBER = DATA_TAB-EBELP.
                          POCONDX-COND_VALUE = 'X'.</b>
                          POCONDX-CURRENCY = 'X'.
                        <b>*  POCONDX-CONEXCHRAT = 'X'.</b>
                          APPEND POCONDX.
                        
                        <b>  POSCHEDULE-PO_ITEM = DATA_TAB-EBELP.</b>
                          POSCHEDULE-DELIVERY_DATE = DATA_TAB-EINDT.
                        <b>  POSCHEDULE-QUANTITY = DATA_TAB-MENGE.</b> 
                          APPEND POSCHEDULE.
                        
                        <b>  POSCHEDULEX-PO_ITEM = DATA_TAB-EBELP. </b> 
                          POSCHEDULEX-DELIVERY_DATE = 'X'.
                        <b>  POSCHEDULEX-QUANTITY = 'X'.</b>
                          APPEND POSCHEDULEX.
                        
                        ENDLOOP.

                         

                        • Re: Error in PO using  BAPI
                          Deesanth Kumar
                          Currently Being Moderated

                          HI Eswar,

                           

                             After i change the still i am getting some return error message as below

                           

                          I   |                    |000   |Creation of PO using Enjoy BAPI unsuccess<

                          E   |MEPO                |000   |Purchase order still contains faulty item<

                          W   |06                  |028   |Purchase order date is in the past       <

                          E   |M3                  |305   |The material 1234567 does not exist or is<

                          E   |M3                  |305   |The material 1234567 does not exist or is<

                          E   |AA                  |001   |Asset 12000003 1 not in company code 2006<

                          W   |ME                  |039   |Delivery date is in the past             <

                          E   |ME                  |078   |Deliv. date outside period covered by fac<

                           

                           

                          Pls check this and correct my code to get the output.

                           

                          Thanks,

                          Rajendra

              • Re: Error in PO using  BAPI
                Khimavath Vikranth
                Currently Being Moderated

                Hi Kumar,

                 

                You have to pass both the item field and as well the flag.other wise it will show the error message.

                <b>POITEMX-PO_ITEM = DATA_TAB-EBELP.

                POITEMX-PO_ITEM = 'X'.</b>(you are just passing this you need to pass the above field also, just as above

                POITEMX-MATERIAL = 'X'.

                POITEMX-SHORT_TEXT = 'X'.

                 

                 

                Thanks

                Vikranth Khimavath

                 

                Message was edited by:

                        Khimavath Vikranth

        • Re: Error in PO using  BAPI
          Deesanth Kumar
          Currently Being Moderated

          Hi,

           

             Now i am getting the below message in theBAPI  RETURN

          E   |MEPO                |085   |Check item number 0 in table POITEMX     <

          E   |MEPO                |085   |Check item number 0 in table POSCHEDULEX <

          E   |MEPO                |085   |Check item number 0 in table POACCOUNT   <

          E   |MEPO                |085   |Check item number 0 in table POACCOUNTX  <

          I   |                    |000   |Creation of PO using Enjoy BAPI unsuccess<

          E   |MEPO                |002   |PO header data still faulty              <

          E   |MEPO                |071   |Item 00010 does not exist                <

          E   |ME                  |015   |Purchasing organization PRD not defined

           

             Now where is the problem and how to solve this.

           

          Thanks,

          Rajendra

Actions