Application Development and Automation 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: 
Read only

Problem using BAPI_REQUISITION_CREATE with service......

ahmad_fajar
Discoverer
0 Likes
694

Hi all,

I have encountered problems using BAPI_REQUISITION_CREATE, for creating PR

with service items.

I know there is some formatting that you have to do

before sending internal table.

It's running great with IDES

but problem occured when dev. on Development Server.

It wouldn't update the service line item.

I tried almost everything and running out ideas.

Heres the code


  DATA: t_return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
  DATA: t_text type BAPIEBANTX.
  DATA: lv_itemcat LIKE t_items-item_cat.
  DATA: lv_serv_line_no LIKE t_service-line_no,
        lv_serv_ext_line LIKE t_service-ext_line,
        lv_pckg_no LIKE t_items-pckg_no,
        lv_item_no LIKE t_items-preq_item,
        lv_serr_no LIKE t_acc_asgmt-serial_no.
 

*  break-point.
  IF t_items[] IS INITIAL.
    gv_msg = 'Item is empty'.
    EXIT.
  ENDIF.

  IF t_service[] IS INITIAL.
    gv_msg = 'Service is empty'.
    EXIT.
  ENDIF.

  IF t_acc_asgmt[] IS INITIAL.
    gv_msg = 'Account assignment is empty'.
    EXIT.
  ENDIF.
  CLEAR: t_items[], t_service[], t_acc_asgmt[],t_serv_acc[],
  t_items, t_service, t_acc_asgmt,t_serv_acc.
** Initial constant for services & package link
  lv_serv_line_no = 1.
  lv_serv_ext_line = 10.
  lv_pckg_no = '0000000001'.
  lv_item_no = '00010'.
  lv_serr_no = 01.

  DATA: RCODE LIKE INRI-RETURNCODE.


  CALL FUNCTION 'NUMBER_GET_NEXT'
       EXPORTING
            NR_RANGE_NR = '01'
            OBJECT = 'SERVICE'
*         QUANTITY = E03
*         SUBOBJECT = E04
*         TOYEAR = E05
       IMPORTING
            NUMBER = lv_pckg_no
*         QUANTITY = I02
            RETURNCODE = RCODE
       EXCEPTIONS
            INTERVAL_NOT_FOUND = 01
            NUMBER_RANGE_NOT_INTERN = 02
            OBJECT_NOT_FOUND = 03
            QUANTITY_IS_0 = 04.

lv_pckg_no = lv_pckg_no + 1.

*BREAK-POINT.
    

COuld anyone double check my coding.

How to fix this?Does anyone else has same problem with me?.

I checked all formatting and structure using BAPI_REQUISTION_GETDETAIL.

It should be allright. As I said Its running on IDES Server but wont on Dev Server

Useful help would be appreciated.

Edited by: fajar.ahmad on Jan 25, 2010 8:28 AM

Edited by: fajar.ahmad on Jan 25, 2010 8:34 AM

2 REPLIES 2
Read only

ahmad_fajar
Discoverer
0 Likes
521
t_items-doc_type = 'SVEN'.
  t_items-del_datcat = '1'. "D
  t_items-deliv_date = '20100201'.
  t_items-plant = 'EN01'.
  t_items-store_loc = 'E101'.
  t_items-pur_group = 'E01'.
  t_items-mat_grp = '0609'.
  t_items-quantity = 1.
  t_items-unit = 'AU'.
  t_items-purch_org = 'ELN'.
  t_items-item_cat = '9'. "D
  t_items-acctasscat = 'K' .
  t_items-short_text = 'SeRVICE Server'.
  t_items-preq_item = lv_item_no.
  t_items-pckg_no = lv_pckg_no.
  APPEND t_items.

  data lv_pckg_tmp like t_service-pckg_no.
  LOOP AT t_items.
    t_service-pckg_no = t_items-pckg_no.
    t_service-subpckg_no = t_service-pckg_no + 1.
    t_service-line_no = lv_serv_line_no.
    t_service-ext_line = 0.
    t_service-outl_ind  = 'X'.
    t_service-from_line  = 1.


    APPEND t_service.
    clear: t_service-outl_ind, t_service-from_line.


    lv_pckg_tmp = t_items-pckg_no + 1.
* LOOP AT T_SERVICE.
    t_service-pckg_no = lv_pckg_tmp.
    t_service-subpckg_no = 0.
    t_service-line_no = t_service-line_no + '0000000001'.
    t_service-ext_line = t_service-ext_line + lv_serv_ext_line.

    t_service-service = '00000000FS00200064'.
    t_service-ext_serv = '999999'.


    t_service-quantity = '1.000'.
    t_service-base_uom = 'AU'.
    t_service-uom_iso = 'PCE'.
    t_service-price_unit = 1.

    t_service-gr_price = '450.000'.
    t_service-short_text = 'Maintenance server'.
    APPEND t_service.

*  END LOOP.

Edited by: fajar.ahmad on Jan 25, 2010 8:43 AM

Read only

ahmad_fajar
Discoverer
0 Likes
521
t_acc_asgmt-serial_no = lv_serr_no.
    t_acc_asgmt-preq_item = t_items-preq_item.
    t_acc_asgmt-preq_qty = t_items-quantity.

    t_acc_asgmt-g_l_acct = '6357120100'.
    t_acc_asgmt-cost_ctr = '001-D-ELN'.
    t_acc_asgmt-CO_AREA  = 'ELN'.
    t_acc_asgmt-PROFIT_CTR = '001-D-ELN'.
    t_acc_asgmt-bus_area = 'ELN'.
*  T_ACC_ASGMT-TO_COSTCTR = 'X'.
    APPEND t_acc_asgmt.

    t_serv_acc-pckg_no = t_service-pckg_no.
    t_serv_acc-line_no = t_service-line_no.
    t_serv_acc-serno_line = t_acc_asgmt-serial_no.
    t_serv_acc-serial_no = t_serv_acc-serno_line.
    t_serv_acc-percentage = '100.0'.
    t_serv_acc-QUANTITY = '1.000'.
    APPEND t_serv_acc.

 ENDLOOP.

  BREAK-POINT.
  CALL FUNCTION 'BAPI_REQUISITION_CREATE'
* EXPORTING
* SKIP_ITEMS_WITH_ERROR =
  IMPORTING
  number = e_number
  TABLES
  requisition_items = t_items
  requisition_account_assignment = t_acc_asgmt
* REQUISITION_ITEM_TEXT =
* REQUISITION_LIMITS =
* REQUISITION_CONTRACT_LIMITS =
   requisition_services = t_service
   requisition_srv_accass_values = t_serv_acc
  return = t_return
* REQUISITION_SERVICES_TEXT =
* EXTENSIONIN =
* REQUISITION_ADDRDELIVERY =
  .
  READ TABLE t_return WITH KEY type = 'E'.

*Function called for commit  read table i_return with key type = 'E'.

    IF sy-subrc <> 0 .
*Function called for commit
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
                wait = 'X'.
      ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    ENDIF.

Best Regards

Edited by: fajar.ahmad on Jan 25, 2010 8:51 AM