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 report

former_member515329
Participant
0 Likes
1,132

i have written report for BDC for creating of sales order by VA01 tcode by uploading a file...i have done with file pickup and populating to perform fields...i m unable to handle table control becoz i may get many materials and quantity feilds to be created for one sales order..my condition is "A separate Sales Order will be created for each combination of Sold-To & Ship-To parties. A Sold-To party may have several Ship-To parties assigned to it. Lines having same combination of SoldTo u2013 ShipTo parties should be added to one Sales Order. A separate Sales Order will be created if a line has different Ship-To party even if the Sold-To remains same "

below is code for it...


loop at i_input_bdc into wa_input_bdc.
perform bdc_dynpro      using 'SAPMV45A' '0101'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-SPART'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.

perform bdc_field       using 'VBAK-AUART'
                              p_auart.
perform bdc_field       using 'VBAK-VKORG'
                              p_vkorg.
perform bdc_field       using 'VBAK-VTWEG'
                              p_vtweg.
perform bdc_field       using 'VBAK-SPART'
                              p_spart.

perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'VBKD-BSTKD'
                              v_po_number.
perform bdc_field       using 'KUAGV-KUNNR'
                              wa_input_bdc-soldto.
perform bdc_field       using 'KUWEV-KUNNR'
                              wa_input_bdc-shipto.
perform bdc_field       using 'VBAK-BSARK'
                              p_bsark.

perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-KWMENG(02)'.
perform bdc_field       using 'RV45A-MABNR(01)'
*                              record-MABNR_01_009.
                              wa_input_bdc-matnr.
perform bdc_field       using 'RV45A-MABNR(02)'
*                              record-MABNR_02_010.
                              wa_input_bdc-matnr.
perform bdc_field       using 'RV45A-KWMENG(01)'
*                              record-KWMENG_01_011.
                              v_kwmeng1.
perform bdc_field       using 'RV45A-KWMENG(02)'
*                              record-KWMENG_02_012.
                              v_kwmeng1.

perform bdc_dynpro      using 'SAPLSPO2' '0300'.
perform bdc_field       using 'BDC_OKCODE'
                              '=OPT1'.


  ON CHANGE OF wa_input_bdc-soldto.
      ON CHANGE OF wa_input_bdc-shipto.

        PERFORM insert_bdc USING 'VA01'.
        CLEAR wa_input_bdc.
        REFRESH i_bdcdata.
*---------------------------------------
      ENDON.
    ENDON.

  ENDLOOP.


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,046

Hi ,

In bdc code, to upload data in table control, do not specify hardcoded number in brakets. Declare one verialble which will be increased by 1 for each record of one sales order. First check how many rows are there in table control for one page. And give the condition if that variable is grater than the rows in one page then use '+P' Ok code ( i.e. Page up), then again reset the variable.

Hope, it will help u.

Thanks,

Poonam.

Hi ,

In bdc code, to upload data in table control, do not specify hardcoded number in brakets. Declare one verialble which will be increased by 1 for each record of one sales order. First check how many rows are there in table control for one page. And give the condition if that variable is grater than the rows in one page then use '+P' Ok code ( i.e. Page up), then again reset the variable.

Hope, it will help u.

Thanks,

Poonam.

6 REPLIES 6
Read only

SujeetMishra
Active Contributor
0 Likes
1,046

Dear Ravi,

can you send me your query in details in code format.

Regards,

Sujeet

Read only

Former Member
0 Likes
1,046

Hi,

Instead of BDC try BAPI BAPI_SALESORDER_CREATEFROMDAT2 to create sales order,

You need to sort the internal table before loop statment.

LOOP AT i_input_bdc INTO wa_input_bdc.
  CLear g_insert.

  ON CHANGE OF wa_input_bdc-soldto.
     G_insert = 'X'.
  ENDON.

  ON CHANGE OF wa_input_bdc-shipto.
    g_insert = 'X'.
  ENDON.

  IF g_insert EQ 'X'.
" Call Bapi or BDC... there is change in the combination
  Endif.

ENDLOOP.

Read only

Former Member
0 Likes
1,046

use BAPI instead, example: BAPI_SALESORDER_CREATEFROMDAT2

regards,darek

Read only

Former Member
0 Likes
1,047

Hi ,

In bdc code, to upload data in table control, do not specify hardcoded number in brakets. Declare one verialble which will be increased by 1 for each record of one sales order. First check how many rows are there in table control for one page. And give the condition if that variable is grater than the rows in one page then use '+P' Ok code ( i.e. Page up), then again reset the variable.

Hope, it will help u.

Thanks,

Poonam.

Read only

0 Likes
1,046

i need to use only BDC..not bapi...i m unable to pass that 'P+' vlaue...

Read only

0 Likes
1,046

Hi,

See the bellow code, which I m using to upload with holding tax data of vendors. In that screen, table control exists which I m using.

LOOP AT ITAB.


IF TEMP_BUKRS <> ITAB-BUKRS OR TEMP_LIFNR <> ITAB-LIFNR.


   IF FLAG EQ 'X'.

    PERFORM BDC_FIELD1       USING 'BDC_OKCODE'
                                '=UPDA'.
    PERFORM BDC_TRANSACTION USING 'XK02'.
    CLEAR FLAG.
    CLEAR V_NO.

  ENDIF.


  PERFORM BDC_DYNPRO1      USING 'SAPMF02K' '0101'.
  PERFORM BDC_FIELD1       USING 'BDC_CURSOR'
                                'RF02K-D0610'.
  PERFORM BDC_FIELD1       USING 'BDC_OKCODE'
                                '/00'.
  PERFORM BDC_FIELD1       USING 'RF02K-LIFNR'
                                  ITAB-LIFNR.
  PERFORM BDC_FIELD1       USING 'RF02K-BUKRS'
                                  ITAB-BUKRS.
  PERFORM BDC_FIELD1       USING 'RF02K-D0610'
                                'X'.


  PERFORM BDC_DYNPRO1      USING 'SAPMF02K' '0610'.

  PERFORM BDC_FIELD1       USING 'BDC_CURSOR'
                                'LFBW-WT_EXDF(01)'.

  PERFORM BDC_FIELD1       USING 'LFBW-WITHT(01)'
                                  ITAB-QSSKZ.

  PERFORM BDC_FIELD1       USING 'LFBW-WT_WITHCD(01)'
                                  ITAB-QSSKZ.

  PERFORM BDC_FIELD1       USING 'LFBW-QSREC(01)'
                                   ITAB-QSREC.

FLAG = 'X'.
ADD 2 TO V_NO.

ELSE.

 IF V_NO NE 6.

CONCATENATE 'LFBW-WT_EXDF(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.
  PERFORM BDC_FIELD1       USING 'BDC_CURSOR'
                                  V_FLD.

CONCATENATE 'LFBW-WITHT(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING  V_FLD
                                ITAB-QSSKZ.

CONCATENATE 'LFBW-WT_WITHCD(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING  V_FLD
                                ITAB-QSSKZ.


CONCATENATE 'LFBW-QSREC(' V_NO ')' INTO V_FLD.
CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING    V_FLD
                                  ITAB-QSREC.

  ADD 1 TO V_NO.

ELSE.

CONCATENATE 'LFBW-WT_EXDF(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.
  PERFORM BDC_FIELD1       USING 'BDC_CURSOR'
                                  V_FLD.

CONCATENATE 'LFBW-WITHT(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING  V_FLD
                                ITAB-QSSKZ.

CONCATENATE 'LFBW-WT_WITHCD(' V_NO ')' INTO V_FLD.
 CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING  V_FLD
                                ITAB-QSSKZ.

CONCATENATE 'LFBW-QSREC(' V_NO ')' INTO V_FLD.
CONDENSE V_FLD.

  PERFORM BDC_FIELD1       USING    V_FLD
                                  ITAB-QSREC.

 perform bdc_field       using 'BDC_OKCODE'
                              '=P+'.

 perform bdc_dynpro      using 'SAPMF02K' '0610'.

 V_NO = 1.

ENDIF.

ENDIF.

TEMP_BUKRS = ITAB-BUKRS.
TEMP_LIFNR = ITAB-LIFNR.

ENLOOP.

Hope, it will help you.

Regards,

Poonam.