Skip to Content
-1
Jan 31 at 10:07 AM

Bapi delivery creation for sales order

483 Views Last edit Jan 31 at 10:51 AM 2 rev

Hi ,

I'm getting error message as inconsistent data in the Bapi call... could you please help me out..

TYPE-POOLS: slis.

TABLES: vbak, vbap.

DATA: BEGIN OF itab_vbak OCCURS 0,

vbeln TYPE vbak-vbeln,

kunnr TYPE vbak-kunnr,

vkorg TYPE vbak-vkorg,

vtweg TYPE vbak-vtweg,

spart TYPE vbak-spart,

bstdk TYPE vbak-bstdk,

END OF itab_vbak.

DATA: BEGIN OF itab_vbap OCCURS 0,

vbeln TYPE vbap-vbeln,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

werks TYPE vbap-werks,

meins TYPE vbap-meins,

vrkme TYPE vbap-vrkme,

END OF itab_vbap.

TYPES: BEGIN OF it_final,

vbeln TYPE vbak-vbeln,

kunnr TYPE vbak-kunnr,

vkorg TYPE vbak-vkorg,

vtweg TYPE vbak-vtweg,

spart TYPE vbak-spart,

bstdk TYPE vbak-bstdk,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

werks TYPE vbap-werks,

meins TYPE vbap-meins,

vrkme TYPE vbap-vrkme,

status TYPE char200,

END OF it_final. *

DATA: gt_final TYPE TABLE OF it_final.

DATA: gv_final TYPE it_final.

TYPES: BEGIN OF ty_message,

status TYPE char200,

END OF ty_message.

DATA: gt_message TYPE STANDARD TABLE OF ty_message,

gv_message TYPE ty_message.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv, gs_fieldcat TYPE slis_fieldcat_alv,

gs_layo TYPE slis_layout_alv.

**Table to Hold Delivery Request

DATA: lv_text TYPE string.

DATA: BEGIN OF tbl_request OCCURS 0.

INCLUDE STRUCTURE bapideliciousrequest. DATA: END OF tbl_request.

*Table to hold Line Items Created

DATA: BEGIN OF tbl_items OCCURS 0.

INCLUDE STRUCTURE bapideliciouscreateditems. DATA: END OF tbl_items.

*Table to hold BAPI Return Messages

DATA: BEGIN OF tbl_return OCCURS 0. INCLUDE STRUCTURE bapiret2.

DATA: END OF tbl_return.

DATA: wa_return TYPE bapiret2.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_VBELN FOR VBAK-VBELN. SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

SELECT vbeln

vkorg

vtweg

spart

bstdk

kunnr FROM vbak INTO CORRESPONDING FIELDS OF TABLE itab_vbak

WHERE vbeln IN s_vbeln.

IF sy-subrc EQ 0.

IF itab_vbak[] IS NOT INITIAL.

SELECT vbeln posnr matnr meins werks vrkme FROM vbap INTO CORRESPONDING FIELDS OF TABLE itab_vbap

FOR ALL ENTRIES IN itab_vbak

WHERE vbeln = itab_vbak-vbeln.

ENDIF.

ENDIF.

gs_fieldcat-col_pos = '1'.

gs_fieldcat-fieldname = 'status'.

gs_fieldcat-seltext_l = 'STATUS'.

gs_fieldcat-outputlen = '200'.

APPEND gs_fieldcat TO gt_fieldcat.

CLEAR gs_fieldcat.

CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC' TABLES request = tbl_request

createditems = tbl_items

return = tbl_return.

LOOP AT tbl_return INTO wa_return. CLEAR:gv_message.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING id = wa_return-id

lang = sy-langu

no = wa_return-number

v1 = wa_return-message_v1

v2 = wa_return-message_v2

v3 = wa_return-message_v3

v4 = wa_return-message_v4

IMPORTING msg = lv_text

EXCEPTIONS not_found = 1 OTHERS = 2. gv_message-status = lv_text.

APPEND gv_message TO gt_message.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = gt_fieldcat

TABLES

t_outtab = gt_message

EXCEPTIONS

program_error = 1

OTHERS = 2.