Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_PR_CREATE enter GL account error

Former Member
0 Kudos

Hi Experts,

I a using babi BAPI_PR_CREATE to create a PR with two line items. but I am getting error 'Enter GL account'.

Please check below program and let me know if anything wrong in it.

data: lv_prnum type BAPIEBANC-PREQ_NO.

data: lv_prnumber type BAPIMEREQHEADER-PREQ_NO.



data: it_req_item type table of BAPIEBANC,

      wa_req_item type BAPIEBANC.



data: it_req_item_new type table of BAPIEBAN,

      wa_req_item_new type BAPIEBAN.



data: it_acc_assig type table of BAPIEBKN,

      wa_acc_assig type BAPIEBKN.



data: it_req_ser type table of BAPIESLLC,

      wa_req_ser type BAPIESLLC.



data: it_ser_val type table of BAPIESKLC,

      wa_ser_val type BAPIESKLC.



data: it_return type table of BAPIRETURN,

      lv_return type BAPIRET2.



data: lv_msg type char50.



data: it_change_return type table of BAPIRET2,

      wa_change_return type BAPIRET2.





data: it_pritem type table of BAPIMEREQITEMIMP,

      wa_pritem type BAPIMEREQITEMIMP.



data: it_pritemx type table of BAPIMEREQITEMX,

      wa_pritemx type BAPIMEREQITEMX.



data: it_pritemexp type table of BAPIMEREQITEM,

      wa_pritemexp type BAPIMEREQITEM.



data: it_praccount type table of BAPIMEREQACCOUNT,

      wa_praccount type BAPIMEREQACCOUNT.



data: it_praccountx type table of BAPIMEREQACCOUNTX,

      wa_praccountx type BAPIMEREQACCOUNTX.



data: it_ret type table of BAPIRET2,

      wa_ret type BAPIRET2.



data: it_prheader type table of BAPIMEREQHEADER,

      wa_prheader type BAPIMEREQHEADER.



data: it_prheaderx type table of BAPIMEREQHEADERX,

      wa_prheaderx type BAPIMEREQHEADERX.



data: it_ser_acc type table of BAPI_SRV_ACC_DATA,

      wa_ser_acc type BAPI_SRV_ACC_DATA.



data: it_ser_accx type table of BAPI_SRV_ACC_DATAX,

      wa_ser_accx type BAPI_SRV_ACC_DATAX.



*first item - material

wa_pritem-PREQ_ITEM = '00010'.

wa_pritem-PUR_GROUP = 'ITD'.

wa_pritem-preq_name = 'abcd'.

wa_pritem-SHORT_TEXT = 'ABC'.

wa_pritem-MATERIAL = 'NCAD100001'.

wa_pritem-PLANT = '1100'.

wa_pritem-TRACKINGNO = 'XXX'.

wa_pritem-MATL_GROUP = 'Z111'.

wa_pritem-QUANTITY = 1.

*wa_pritem-UNIT = 'AU'.

wa_pritem-PREQ_DATE = '20140430'.

wa_pritem-DELIV_DATE = '20140505'.

wa_pritem-PRICE_UNIT = 1.

*wa_pritem-ITEM_CAT = ' '.

wa_pritem-ACCTASSCAT = 'N'.

*wa_pritem-des_vendor = '0050000793'.

*wa_pritem-fixed_vend = '0050000793'.

wa_pritem-PURCH_ORG = '1000'.

append wa_pritem to it_pritem.



*2nd item - service

clear wa_pritem.

wa_pritem-PREQ_ITEM = '00020'.

wa_pritem-PUR_GROUP = 'ITD'.

wa_pritem-preq_name = 'abc'.

wa_pritem-SHORT_TEXT = 'ABC'.

*wa_pritem-MATERIAL = 'NCAD100002'.

wa_pritem-PLANT = '1100'.

wa_pritem-TRACKINGNO = 'XXX'.

wa_pritem-MATL_GROUP = 'S0010'.

wa_pritem-QUANTITY = 1.

*wa_pritem-UNIT = 'AU'.

wa_pritem-PREQ_DATE = '20140430'.

wa_pritem-DELIV_DATE = '20140505'.

wa_pritem-PRICE_UNIT = 1.

wa_pritem-ITEM_CAT = '9'.

wa_pritem-ACCTASSCAT = 'N'.

*wa_pritem-des_vendor = '0050000793'.

*wa_pritem-fixed_vend = '0050000793'.

wa_pritem-PURCH_ORG = '1000'.

wa_pritem-pckg_no = '0000000001'.

append wa_pritem to it_pritem.



*fields for  1st item - material

wa_pritemx-PREQ_ITEM = '00010'.

wa_pritemx-PREQ_ITEMX = 'X'.

wa_pritemx-PUR_GROUP = 'X'.

wa_pritemx-preq_name = 'X'.

wa_pritemx-SHORT_TEXT = 'X'.

wa_pritemx-MATERIAL = 'X'.

wa_pritemx-PLANT = 'X'.

wa_pritemx-TRACKINGNO = 'X'.

wa_pritemx-MATL_GROUP = 'X'.

wa_pritemx-QUANTITY = 'X'.

*wa_pritem-UNIT = 'AU'.

wa_pritemx-PREQ_DATE = 'X'.

wa_pritemx-DELIV_DATE = 'X'.

wa_pritemx-PRICE_UNIT = 'X'.

*wa_pritem-ITEM_CAT = ' '.

wa_pritemx-ACCTASSCAT = 'X'.

*wa_pritemx-des_vendor = 'X'.

*wa_pritemx-fixed_vend = 'X'.

wa_pritemx-PURCH_ORG = 'X'.

append wa_pritemx to it_pritemx.



*fields for  2nd item - service

clear wa_pritemx.

wa_pritemx-PREQ_ITEM = '00020'.

wa_pritemx-PREQ_ITEMX = 'X'.

wa_pritemx-PUR_GROUP = 'X'.

wa_pritemx-preq_name = 'X'.

wa_pritemx-SHORT_TEXT = 'X'.

wa_pritemx-MATERIAL = 'X'.

wa_pritemx-PLANT = 'X'.

wa_pritemx-TRACKINGNO = 'X'.

wa_pritemx-MATL_GROUP = 'X'.

wa_pritemx-QUANTITY = 'X'.

*wa_pritem-UNIT = 'X'.

wa_pritemx-PREQ_DATE = 'X'.

wa_pritemx-DELIV_DATE = 'X'.

wa_pritemx-PRICE_UNIT = 'X'.

wa_pritem-ITEM_CAT = 'X'.

wa_pritemx-ACCTASSCAT = 'X'.

*wa_pritemx-des_vendor = 'X'.

*wa_pritemx-fixed_vend = 'X'.

wa_pritemx-PURCH_ORG = 'X'.

wa_pritem-pckg_no = 'X'.

append wa_pritemx to it_pritemx.



*Account assignment data for 1st item - material

wa_praccount-PREQ_ITEM = '00010'.

wa_praccount-SERIAL_NO = '01'.

wa_praccount-QUANTITY = 1.

wa_praccount-DISTR_PERC = '1.00'.

wa_praccount-NET_VALUE = 1.

wa_praccount-GL_ACCOUNT = '0040100801'.

wa_praccount-UNLOAD_PT = 'ABC'.

wa_praccount-CO_AREA = '1000'.

wa_praccount-NETWORK = '000004011841'.

append wa_praccount to it_praccount.



*Account assignment data for 2nd item - service

clear wa_praccount.

wa_praccount-PREQ_ITEM = '00020'.

wa_praccount-SERIAL_NO = '02'.

*wa_praccount-QUANTITY = 1.

*wa_praccount-DISTR_PERC = '1.00'.

*wa_praccount-NET_VALUE = 1.

wa_praccount-GL_ACCOUNT = '0040100801'.

wa_praccount-UNLOAD_PT = 'ABC'.

wa_praccount-CO_AREA = '1000'.

wa_praccount-NETWORK = '000004011841'.

append wa_praccount to it_praccount.



*Account assignment fields for 1st item - material

wa_praccountx-PREQ_ITEM = '00010'.

wa_praccountx-SERIAL_NO = '01'.

wa_praccountx-PREQ_ITEMX = 'X'.

wa_praccountx-SERIAL_NOX = 'X'.

wa_praccountx-QUANTITY = 'X'.

wa_praccountx-DISTR_PERC = 'X'.

wa_praccountx-NET_VALUE = 'X'.

wa_praccountx-GL_ACCOUNT = 'X'.

wa_praccountx-UNLOAD_PT = 'X'.

wa_praccountx-CO_AREA = 'X'.

wa_praccountx-NETWORK = 'X'.

append wa_praccountx to it_praccountx.



*Account assignment fields for 2nd item - service

clear wa_praccountx.

wa_praccountx-PREQ_ITEM = '00020'.

wa_praccountx-SERIAL_NO = '02'.

wa_praccountx-PREQ_ITEMX = 'X'.

wa_praccountx-SERIAL_NOX = 'X'.

*wa_praccountx-QUANTITY = 'X'.

*wa_praccountx-DISTR_PERC = 'X'.

*wa_praccountx-NET_VALUE = 'X'.

wa_praccountx-GL_ACCOUNT = 'X'.

wa_praccountx-UNLOAD_PT = 'X'.

wa_praccountx-CO_AREA = 'X'.

wa_praccountx-NETWORK = 'X'.

append wa_praccountx to it_praccountx.



*2nd item Service  details

wa_ser_acc-doc_item = '00020'.

wa_ser_acc-outline = '0000000001'.

wa_ser_acc-srv_line = '0000000010'.

wa_ser_acc-serial_no = '02'.

wa_ser_acc-serial_no_item = '02'.

wa_ser_acc-quantity = 10.

append wa_ser_acc to it_ser_acc.



*2nd item Service  fields

wa_ser_accx-doc_item = '00020'.

wa_ser_accx-outline = '0000000001'.

wa_ser_accx-srv_line = '0000000010'.

wa_ser_accx-serial_no = '02'.

wa_ser_accx-serial_no_item = 'X'.

wa_ser_accx-quantity = 'X'.

append wa_ser_accx to it_ser_accx.



*Header details

wa_prheader-pr_type = 'PURE'.

wa_prheaderx-pr_type = 'X'.





CALL FUNCTION 'BAPI_PR_CREATE'

  EXPORTING

    PRHEADER                     = wa_prheader

    PRHEADERX                    = wa_prheaderx

*   TESTRUN                      =

  IMPORTING

    NUMBER                       = lv_prnumber

*   PRHEADEREXP                  =

  TABLES

    RETURN                       = it_ret

    PRITEM                       = it_pritem

    PRITEMX                      = it_pritemx

*    PRITEMEXP                    = it_pritemexp

*   PRITEMSOURCE                 =

    PRACCOUNT                    = it_praccount

*   PRACCOUNTPROITSEGMENT        =

    PRACCOUNTX                   = it_praccountx

*   PRADDRDELIVERY               =

*   PRITEMTEXT                   =

*   PRHEADERTEXT                 =

*   EXTENSIONIN                  =

*   EXTENSIONOUT                 =

*   PRVERSION                    =

*   PRVERSIONX                   =

*   ALLVERSIONS                  =

*   PRCOMPONENTS                 =

*   PRCOMPONENTSX                =

*   SERVICEOUTLINE               =

*   SERVICEOUTLINEX              =

*   SERVICELINES                 =

*   SERVICELINESX                =

*   SERVICELIMIT                 =

*   SERVICELIMITX                =

*   SERVICECONTRACTLIMITS        =

*   SERVICECONTRACTLIMITSX       =

    SERVICEACCOUNT               = it_ser_acc

    SERVICEACCOUNTX              = it_ser_accx

*   SERVICELONGTEXTS             =

*   SERIALNUMBER                 =

*   SERIALNUMBERX                =

          .



IF sy-subrc eq 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     WAIT          = 'X'

   IMPORTING

     RETURN        = lv_return.

endif.

1 REPLY 1

Former Member
0 Kudos

Hi

Now i able to post PR. I DID BELOW CHANGE. I ADDED serrial no.

Ls_acct-SERIAL_NO = '01'.

Ls_acct-COSTCENTER = gs_psdata-kostl.

Ls_acct-WBS_ELEMENT gs_psdata-wbs_element.

append ls_acct to lt_acct.

Ls_acctx-SERIAL_NO = '01'.

Ls_acctx-COSTCENTER = GC_X.

Ls_acctX-WBS_ELEMENT = GC_X.

append ls_acctx to lt_acctx.



But second issue i am facing


i am using item category 'L' subcontracting


i am trying to replace existing BOM with new material USING BELOW LOGIC.


LS_COMP-MATERIAL gs_psdata-COMP_MATNR.  " Ne material act as component of product

LS_COMP-PLANT = gs_psdata-werks.

LS_COMP-CHANGE_ID = 'I'. "gc_value_r.

LS_COMP-ENTRY_QUANTITY gs_psdata-QUANTITY.

APPEND LS_COMP TO LT_COMP.

CLEAR LS_COMP.

*LS_COMPx-PREQ_ITEM = '00010'.

LS_COMPX-MATERIAL = GC_X.

LS_COMPx-PLANT = gc_x.

LS_COMPX-CHANGE_ID = GC_X.

LS_COMPX-ENTRY_QUANTITY = GC_X.

APPEND LS_COMPX TO LT_COMPX.

CLEAR LS_COMPX.



But i observed that  old BOM is pulled into PR. and not appeared my material added in above logic.



Any advise.


Regards

Ramakrishnaiah Y