Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Goods Receipt confirmation of Purchase Order

$
0
0

Hi,

 

I am .Net developer and working on the SAP integration with VB.Net. I am using RFC connector to connect SAP and post data.

 

I have a BAPI method already developed to post Goods Receipt transaction into SAP against Purchase Order.

 

This BAPI method is successfully creating goods receipt transaction into SAP, if I directly put values into BAPI using SE78 command inside SAP.

But the problem is when I am passing the same values from .Net application, SAP is not creating goods receipt transaction.

 

I tried lot of things and I noticed there might be the issue with Delivery Date and Document Date which I am passing in .Net string format "yyyyMMdd"

 

The problem is BAPI method is not even throwing any error or returning error message through RESULT table. Inside ABAP there is one RESULT table, which has to be filled with error message in case of any error.

 

I have another BAPI method for Transport Order Goods Issue from one plant to another plant. Same issue with this ABAPI also, but in this after executing method RESULT table is filled with error message, which is "Posting Date is Initial". So i guess some issue with Posting/Delivery date when i am passing it.

 

Kindly help me in this regard. I really appreciate it.

 

Best Regards,

 

Jawad Hussain.

 

BAPI Method Detail is as below:

 

Table   : ZBAPI_AGI_PC_TBL

Table   : ZBAPI_AGI_PO_RESULTS

FGroup : ZBAPI_AGI_PC

BAPI    : ZBAPI_AGI_PO_CONFIRMATION

 

BAPI CODE:

 

FUNCTION ZBAPI_AGI_PO_CONFIRMATION.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  TABLES

*"      ITEMTAB STRUCTURE  ZBAPI_AGI_PC_TBL

*"      RESULTS STRUCTURE  ZBAPI_AGI_PO_RESULTS

*"----------------------------------------------------------------------

 

DATA: gt_goodsmvt_header  LIKE bapi2017_gm_head_01,

      gt_goodsmvt_item    LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,

      gt_return           LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: gt_goodsmvt_headret LIKE bapi2017_gm_head_ret,

      goodsmvt_code_tmp   TYPE bapi2017_gm_code,

      testrun             TYPE c VALUE 'X'.

    data: l_return like BAPIRET2.

 

TABLES lips.

 

* PARAMETERS p_vbeln LIKE lips-vbeln. " Delivery number

 

* START-OF-SELECTION.

  gt_goodsmvt_header-pstng_date = sy-datum.

  gt_goodsmvt_header-doc_date   = sy-datum.

 

  LOOP AT ITEMTAB.

    gt_goodsmvt_item-move_type            =  '101' .

    gt_goodsmvt_item-mvt_ind              =  'B'.

    gt_goodsmvt_item-no_more_gr           = 'X'.

    gt_goodsmvt_item-deliv_numb_to_search =  ITEMTAB-DeliveryNo.

    gt_goodsmvt_item-deliv_item_to_search =  ITEMTAB-ItemNumber.

    gt_goodsmvt_item-material             =  ITEMTAB-MaterialCode.

    gt_goodsmvt_item-entry_qnt            =  ITEMTAB-Quantity.

    gt_goodsmvt_item-entry_uom            =  ITEMTAB-UnitOfMeasure.

    gt_goodsmvt_item-Batch                =  ITEMTAB-Batch.

*    gt_goodsmvt_item-plant                =  ITEMTAB-PlantCode.

    gt_goodsmvt_item-stge_loc             =  ITEMTAB-StorageLocationCode.

*    gt_goodsmvt_item-po_number            =  ITEMTAB-ReferenceDoc.

*    gt_goodsmvt_item-po_item              =  ITEMTAB-ReferenceItem.

 

              SELECT SINGLE WERKS

              INTO gt_goodsmvt_item-plant

              FROM LIPS

              WHERE VBELN = ITEMTAB-DeliveryNo

              AND POSNR = ITEMTAB-ItemNumber.

 

    IF ITEMTAB-Batch = ''.

    SELECT SINGLE CHARG

    INTO ITEMTAB-Batch

    FROM LIPS

    WHERE VBELN = ITEMTAB-DeliveryNo

    AND POSNR = ITEMTAB-ItemNumber.

    ENDIF.

 

    IF ITEMTAB-StorageLocationCode = ''.

    SELECT SINGLE LGORT

    INTO ITEMTAB-StorageLocationCode

    FROM LIPS

    WHERE VBELN = ITEMTAB-DeliveryNo

    AND POSNR = ITEMTAB-ItemNumber.

 

    ENDIF.

    APPEND  gt_goodsmvt_item.

  ENDLOOP.

  goodsmvt_code_tmp =          '01'. "Assign code to transaction for BAPI goods movement

****<<<<<<<Post goods movements with MB_CREATE_GOODS_MOVEMENT>>>>>>>>>>>>>>>>>>>

  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

    EXPORTING

      goodsmvt_header          = gt_goodsmvt_header

      goodsmvt_code            = goodsmvt_code_tmp

*      testrun                  = testrun

   IMPORTING

     goodsmvt_headret          =  gt_goodsmvt_headret

    TABLES

      goodsmvt_item            = gt_goodsmvt_item

*   GOODSMVT_SERIALNUMBER       =

      return                   = gt_return.

 

  IF gt_return[] IS INITIAL.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       WAIT          = 'X'

     IMPORTING

       RETURN        = l_return.

 

*    WRITE:/3  'ASN Number', gt_goodsmvt_item-deliv_numb_to_search,

*          /3  'Item',gt_goodsmvt_item-deliv_item_to_search.

    ENDIF.

    read table gt_return.

 

 

* ----------------------------------------------------------------------------

LOOP AT gt_return.

 

* WRITE:/ gt_return-Type,gt_return-ID, gt_return-NUMBER, gt_return-MESSAGE.

 

RESULTS-TYPE      = gt_return-TYPE.

RESULTS-ID        = gt_return-ID.

RESULTS-V_NUMBER    = gt_return-NUMBER.

RESULTS-MESSAGE   = gt_return-MESSAGE.

RESULTS-LOG_NO      = gt_return-LOG_NO.

RESULTS-LOG_MSG_NO  = gt_return-LOG_MSG_NO.

RESULTS-MESSAGE_V1  = gt_return-MESSAGE_V1.

RESULTS-MESSAGE_V2  = gt_return-MESSAGE_V2.

RESULTS-MESSAGE_V3  = gt_return-MESSAGE_V3.

RESULTS-MESSAGE_V4  = gt_return-MESSAGE_V4.

RESULTS-V_PARAMETER  = gt_return-PARAMETER.

RESULTS-V_ROW        = gt_return-ROW.

RESULTS-FIELD      = gt_return-FIELD.

RESULTS-V_SYSTEM      = gt_return-SYSTEM.

 

 

APPEND RESULTS.

 

ENDLOOP.

 

 

* ---------------------------------------------------------------------------

 

ENDFUNCTION.

 

 

.NET CODE:

 

func = SAPsession.ImportCall("ZBAPI_AGI_PO_CONFIRMATION")

 

Row = func.Tables("ITEMTAB").Rows.AddRow()

Row("DELIVERYNO").value = Convert.ToString(TbRow("DeliveryNo"))

Row("DOCUMENTDATE").value = Convert.ToDateTime(TbRow("DocumentDate")).ToString("yyyyMMdd")

Row("POSTINGDATE").value = Convert.ToDateTime(TbRow("PostingDate")).ToString("yyyyMMdd")

Row("ITEMNUMBER").value = Convert.ToInt32(TbRow("ItemNumber")).ToString()

Row("BARCODE").value = Convert.ToString(TbRow("MaterialBarcode"))

Row("MATERIALCODE").value = Convert.ToInt64(TbRow("MaterialCode")).ToString()

Row("QUANTITY").value = CDec(TbRow("Quantity"))

Row("UNITOFMEASURE").value = Convert.ToString(TbRow("UnitOfMeasure"))

Row("BATCH").value = Convert.ToString(TbRow("Batch"))

Row("STORAGELOCATIONCODE").value = Convert.ToString(TbRow("StorageLocationCode"))

SAPsession.CallFunction(func)


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>