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

BDC Error

Former Member
0 Likes
1,533

Hi All,

I did the BDC program for sales order creation and here I read the file as each line seperately to get the data.

The program was working fine for line items < 7, as we are getting more line items in single PO now I changed the program to include this condition also.

The error is program is working for line items > 7 now and for line items <= 7 it is giving the error "No batch input data for screen SAPMV45A 4001" and stuck at the error.

I am sending part of the code, can you please help me what i am doing wrong with this.

Thanks

Veni.


FORM populate_data .
  data: lv_po(35) type c,
        gv_num(5) type n value '00001',
        gv_fname1(132) type c,
        gv_fname2(132) type c,
        gv_fname3(132) type c,
        GV_FNAME4(132) TYPE C,
        lv_price(13) type c.

  Loop at gt_sdata INTO gs_sdata.

    if lv_po ne gs_sdata-bstkd.
      lv_po = gs_sdata-bstkd.

      clear: gv_fname1, gv_fname2, gv_fname3, gv_fname4.

      perform bdc_dynpro      using 'SAPMV45A' '0101'.
      perform bdc_field       using 'BDC_CURSOR' 'VBAK-AUART'.
      perform bdc_field       using 'BDC_OKCODE' '/00'.
      perform bdc_field       using 'VBAK-AUART' 'OR'.
      perform bdc_field       using 'VBAK-VKORG' '300'.
      perform bdc_field       using 'VBAK-VTWEG' '20'.
      perform bdc_field       using 'VBAK-SPART' '01'.

      perform bdc_dynpro      using 'SAPMV45A' '4001'.
      perform bdc_field       using 'BDC_OKCODE' '=POAN'.
      perform bdc_field       using 'VBKD-BSTKD' gs_sdata-BSTKD.
      perform bdc_field       using 'VBKD-BSTDK' gs_sdata-BSTDK.
      perform bdc_field       using 'KUAGV-KUNNR' '1195'.
      perform bdc_field       using 'KUWEV-KUNNR' gs_sdata-KUNNR1.
      perform bdc_field       using 'RV45A-KETDAT' GS_SDATA-KETDAT.
      perform bdc_field       using 'RV45A-KPRGBZ' 'D'.

    endif.

    concatenate 'RV45A-KWMENG(' gv_num ')' INTO GV_FNAME1.
    concatenate 'VBAP-POSNR(' gv_num ')' INTO GV_FNAME2.
    concatenate 'RV45A-MABNR(' gv_num ')' INTO GV_FNAME3.
    concatenate 'KOMV-KBETR(' gv_num ')' INTO GV_FNAME4.

    SELECT KNUMH FROM A951
    INTO TABLE IT_A951
    WHERE KAPPL = 'V'
    AND KSCHL = 'PR00'
    AND MATNR = gs_sdata-MABNR
    AND DATBI > SY-DATUM.

    READ TABLE IT_A951 INDEX 1.

*    CHECK NOT IT_A951 IS INITIAL.
    If NOT IT_A951 IS INITIAL.

      SELECT KNUMH KBETR FROM KONP
      INTO TABLE IT_KONP
      FOR ALL ENTRIES IN IT_A951
      WHERE KNUMH = IT_A951-KNUMH.

      Read table IT_KONP with key KNUMH = IT_A951-KNUMH.
      clear lv_price.
      if sy-subrc = 0.
        lv_price = IT_KONP-KBETR.
      endif.
    Endif.

    perform bdc_field       using 'BDC_CURSOR' 'KOMV-KBETR(001)'.
    perform bdc_field       using GV_FNAME1 gs_sdata-kwmeng.
    perform bdc_field       using GV_FNAME2 gs_sdata-posnr.
    perform bdc_field       using GV_FNAME3 gs_sdata-mabnr.
    perform bdc_field       using GV_FNAME4 lv_price.

    IF gv_num = 7.
    	gv_num = 1.
      	perform bdc_dynpro      using 'SAPMV45A' '4001'.
      perform bdc_field       using 'BDC_OKCODE' '=KKAU'.

    ENDIF.

    clear gs_sdata.
    clear it_a951.
    clear it_konp.
    gv_num = gv_num + 1.

    AT END of BSTKD.

      perform bdc_dynpro      using 'SAPMV45A' '4002'.
      perform bdc_field       using 'BDC_OKCODE' '=SICH'.
      perform bdc_field       using 'BDC_CURSOR' 'VBAK-GWLDT'.
      perform bdc_field       using 'VBAK-GWLDT' '12/31/2007'.

      perform bdc_transaction using 'VA01'.
      gv_num = 1.
      clear gs_sdata.
      l2_num = l2_num + 1.
    ENDAT.

  Endloop.
ENDFORM.                    " populate_data

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,460

Hi,

You are refreshing the BDCDATA internal table right after the call transaction??

Thanks

Naren

13 REPLIES 13
Read only

Former Member
0 Likes
1,460

Hi,

I would suggest using the BAPI BAPI_SALESORDER_CREATEFROMDAT2 instead of using BDC.

Thanks,

Naren

Read only

0 Likes
1,460

Hi Veni,

This is a typical problem with BDC. To run BDC without any error, your recording environment and execution environment should be identical.

You are facing problem because during recording, no. of items visible must be > 7 . During execution, the BDC recorded program doesnt find space or any recording for scroll down to enter eighth item. causing error.

Follow the BAPI method.

thak,

bye.

Read only

0 Likes
1,460

Hi Naren/Audumber,

Thank you for your answer.

This program is working with line items > 7, when a PO with < 7 line items is there then it is stuking. It is not going to the next screen.

I know BAPI is the best, but I have to fix this by tomorrow morning.

We are going to get Edi invoices very soon, then no need of this program at all.

Please give me some suggetion to fix this.

Thanks

Veni.

Read only

Former Member
0 Likes
1,460

Hi,

Give the mode = 'A' then check where exactly you are getting stuck.

Thanks,

Naren

Read only

0 Likes
1,460

Hi Naren,

I used one file with 3 PO's in it. 1st one with 9 line item 2nd one with 11 line items and 3rd one with 3 line items. First two PO's processed properly and sales orders created for those, third one with 3 line items, after clicking yes to okcode for 3 line items it went into add more line items like items > 7 and staying there to enter more line items.

After screen 4001 'BDC_OKCODE' '=POAN' it is going to 4001 'BDC_OKCODE' '=KKAU' instead of directly going to 4002 'BDC_OKCODE' '=SICH.

Please help me to rectify this prpblem.

Thank you,

Veni.

Read only

0 Likes
1,460

Hi Veni

you have mentioned

"After screen 4001 'BDC_OKCODE' '=POAN' it is going to 4001 'BDC_OKCODE' '=KKAU' instead of directly going to 4002 'BDC_OKCODE' '=SICH."

but in ur code

"IF gv_num = 7.

gv_num = 1.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE' '=KKAU'.

ENDIF."

it will go to SAPMV45A' '4001' only if gv_num = 7. but in you case it will be less then 7.

i think it should work. Just check in debugging mode...why its going inside this if condition. Because it should not match if line items are less then 7.

Best Regards

Naresh

Read only

Former Member
0 Likes
1,461

Hi,

You are refreshing the BDCDATA internal table right after the call transaction??

Thanks

Naren

Read only

0 Likes
1,460

Hi Naren,

I am using standard include BDCRECX1, in that I see REFRESH BDCDATA in FORM BDC_TRANSACTION USING TCODE just before ENDFORM. Do you think i should copy this and change it.

Hi Naresh,

yes, It should not go into 'IF gv_num = 7' because it is not satisfying.

When I debug in Call transaction mode at perform bdc_field, it is taking 3 line items, then going to 4001 - KKAU and staying there.

Here I tried to come out, it is not going to AT END of BSTKD and 3rd screen for GWLDT - cancellation date, but going to

"perform bdc_transaction using 'VA01'." and asking for cacellation date. I gave cancellation date manually and saved it.

S Missing data: Guarantee

S Function code cannot be selected

S The document is complete

S Standard Order 647134 has been saved

Please help me.

Thanks

Veni.

Read only

0 Likes
1,460

Hi Venny

The problem seems to me is why its going to 4001 - KKAU. if condition is not satisfying. this you can check in debugging mode and regarding entering in endat againg whether

BSTKD is changing at that record.

Please check in debugging

Naresh

Read only

0 Likes
1,460

you can use the logic in the IDOC_INPUT_ORDERS as an example on how to populate BDC for VA01 (for any number of items).

I would just use POAN for each new item, it will scroll the list and make the new item - the 2st item on the screen (it's true for all tiems except the 1st one).

so, if your gv_num > 1, use 'POAN' and then update values on the 2nd line :

perform bdc_field using 'RV45A-KWMENG(2)' gs_sdata-kwmeng.

Read only

0 Likes
1,460

Hi Naren,Audumber,Naresh and Siarhei,

Thank you very much for all your help.

I really appritiate your help.

Thanks,

Veni.

Read only

Former Member
0 Likes
1,460

Hi,

Could you please post the data declaration of the internal table gt_sdata..

Thanks,

Naren

Read only

0 Likes
1,460

Hi Naren,

Types: begin of ty_sdata,

BSTKD(35) TYPE C, "Cust pur order number

POSNR(06) TYPE C, "Sales document item

BSTDK(10) type c, "Customer purchase order date

GWLDT(08) type C, "Guarantee date

KETDAT(10) TYPE C, "Req delivery date

MABNR(18) TYPE C, "Material number

KWMENG(18) TYPE C, "Cumulative order qty

KUNNR1(10) TYPE C, "Ship-to party

KBETR(13) TYPE C, "Rate

End of ty_sdata.

DATA: gt_sdata type table of ty_sdata,

gs_sdata type ty_sdata.

gt_sdata will have all data.

gs_sdata will have only one line at a time.

Thanks

Veni.