5 1 1 1 1 1 Rating 100% (1 Vote)

This time the problem which I solved was not an ABAP problem, although at the beginning I thought it is, as while creating of deliveries without reference in standard transaction were done correctly without any issues, then when I tried to do it in ABAP, I always received the error VL473 - Copying is not poss.because an entry is missing in Table TVCPL. 

I thought that this is some kind of nonsense as with standard t-code it was working correctly, so I tried several FM to create deliveries without reference but always with the same result as you can see on picture bellow. 

Then I did what I should do from beginning. I used where used function to display where TVCPL table is used and I found two views V_TVCPLAK and V_TVCPLAP.

I started with the first one as from experience I know that if SAP table had K at the end of the name that this must be configuration of header (Kopf).

I've inserted my new delivery type as target delivery type and I've filled data transfer of header data with 301 - which is a special routine for delivery header without reference.

I've run my code again, and I was surprised that I have still the same error message.

But when I double clicked on details I saw that there is now additional info beside delivery type.

  

I guessed that I have to open the second view now and this was what I did.

This time I've entered item category which was visible in error details and I user routine 302 for data transfer of item data without reference order.

  

Once saved I rerun the program and finally I received positive result.

    

The conclusion is: do not assume that if something is workning in standard transaction, will work also in BAPI without additional settings :-) 

 

Bellow you can find piece of code which I used to create outbound delivery without reference document.

 

  method create_delivery_wo.
    data:    error_log     type                   bapiret2_t,
             dates         type standard table of bapidlvdeadln,
             dlv_items     type standard table of bapidlvnorefitem,
             created_items type standard table of bapidlvitemcreated,
             timestamp     type                   timestamp.


    insert value #(   material c_source-matnr
                      dlv_qty c_source-bdmng
                      sales_unit c_source-meins
                      plant  c_source-werks
                   into table dlv_items.

    get time stamp field timestamp.

    "delivery date
    insert value #(  timetype 'WSHDRLFDAT'
                     timestamp_utc  timestamp
                     timezone  sy-zonlo
                     into table dates.

    "Goods issue date
    insert value #(  timetype 'WSHDRWADAT'
                      timestamp_utc  timestamp
                      timezone  sy-zonlo
                    into table dates.


    call function 'BAPI_OUTB_DELIVERY_CREATENOREF'
      exporting
        ship_point    del_shipping_point    " Shipping Point
        dlv_type      'ZLO0'    " Delivery Type
        salesorg      del_sales_org   " Sales Organization
        distr_chan    '90'    " Distribution Channel
        division      '99'    " Division
        ship_to       c_source-kunnr   " Goods Recipient
      tables
        dates         dates    " Delivery Deadlines
        dlv_items     dlv_items    " Delivery Item Without Reference
        created_items created_items    " Generated Delivery Items
        return        error_log.    " Return Parameter(s)

    append lines of error_log to bapi_log.
    loop at error_log assigning field-symbol(<err>where type ca 'EAX'.
      exit.
    endloop.
    if sy-subrc ne 0.
      commit work.
    else.
      rollback work.
    endif.

  endmethod.

Enjoy!