cancel
Showing results for 
Search instead for 
Did you mean: 

BDC

Former Member
0 Kudos
133

Hi,

I need help with my BDC program.

This is for transaction VF01 - automatically create a credit note.

There are only 2 fields that i will use, billing type and document number. As for billing type, i want to make sure its always constant at YG2 and for document number, i will extract from a vbrk-vbeln.

There is no file uploading involved.

I am having touble with both fields.

Can anyone help with the coding?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi.. yes, the batch is created in SM35.

there is a problem with this part of the code:

PERFORM bdc_field USING 'KOMFK-VBELN' "SD document number

it_display-vbeln.

the value from it_display-vbeln does not update komfk-vbeln. there is a value in it_display-vbeln.

Message was edited by: Charlene Tan

Former Member
0 Kudos

Please check if you have missed specifying the record number:

perform bdc_field using 'KOMFK-VBELN<b>(01)</b>'

it_display-vbeln.

Kind Regards

Eswar

Former Member
0 Kudos

Hi Charlene...is u again..hehe

your coding:

perform bdc_field using 'KOMFK-VBELN(01)'

it_display-vbeln.

I think your internal table values it_display-vbeln is overwriting the values in 'KOMFK-VBELN(01)'. When the coding is 'KOMFK-VBELN(01)', it means KOMFK-VBELN is always pointing on line item no 1. If you wish to pass your value to line item no 2, please use a counter and assign it to KOMFK-VBELN.

Answers (11)

Answers (11)

Former Member
0 Kudos

Thanks alot for helping me & tolerating with me Eswar!

Former Member
0 Kudos

Glad could help you Charlene.

Kind Regards

Eswar

Former Member
0 Kudos

Hi Charlene,

I think your internal table is without header line.

DATA: BEGIN OF it_display OCCURS 0,

fkart LIKE RV60A-FKART,

vbeln LIKE vbrk-vbeln,

END OF it_display.

when you loop your internal table, put the value into a working area.

for example:

declare your working area like below:

Data: wa_display like it_display.

LOOP at it_display into wa_display.

...

...

...

ENDloop.

Former Member
0 Kudos

Hi..thanks for the help.

The BDC runs through smoothly but the values in the fields RV60A-FKART and KOMFK-VBELN are not being updated, hence, the record is not created.

I am really puzzled at this point.

please help. thank you.

Former Member
0 Kudos

Have you checked the session that is created, please check the session via SM35.

Do execute the session in foreground mode to check if the values are populated. If not, debug the program to check whether the values are existing while passing to the session.

Kind Regards

Eswar

Former Member
0 Kudos

*----


*

DATA: BEGIN OF it_display OCCURS 0,

fkart LIKE RV60A-FKART,

vbeln LIKE vbrk-vbeln,

END OF it_display.

*----


*

*----


*

IF VBRK-VKORG EQ '9083' AND ( VBRK-KONDA EQ 'Y1' OR VBRK-KONDA EQ 'Y2' ) . "sales org and price group must fit criteria

PERFORM get_data.

PERFORM bdc_posting.

message S003(z000).

ELSE.

message S004(z000).

ENDIF.

*----


*

*----


*

FORM bdc_posting.

LOOP AT it_display.

PERFORM bdc_open.

BDCDATA-PROGRAM = 'SAPMV60A'.

BDCDATA-DYNPRO = '0102'.

BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = 'BDC_CURSOR'.

BDCDATA-FVAL = 'KOMFK-VBELN'.

BDCDATA-FNAM = 'BDC_OKCODE'.

BDCDATA-FVAL = '/00'.

BDCDATA-FNAM = 'RV60A-FKART'. "billing type

BDCDATA-FVAL = 'YG2'.

BDCDATA-FNAM = 'KOMFK-VBELN'. "SD document number

BDCDATA-FVAL = it_display-vbeln.

BDCDATA-PROGRAM = 'SAPMV60A'.

BDCDATA-DYNPRO = '0103'.

BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = 'BDC_CURSOR'.

BDCDATA-FVAL = '*TVFKT-VTEXT(01)'.

BDCDATA-FNAM = 'BDC_OKCODE'.

BDCDATA-FVAL = '=SICH'.

PERFORM bdc_transaction1 USING 'ZVF01'.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDLOOP.

ENDFORM.

*----


*

*----


*

FORM get_data.

MOVE: vbrk-vbeln TO it_display-vbeln.

APPEND it_display.

ENDFORM. "get_data

FORM bdc_open .

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'M__MATGRLOAD'

user = SY-UNAME

keep = 'X'.

ENDFORM. " bdc_open

FORM bdc_transaction1 USING tcode.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'ZVF01'

TABLES

dynprotab = bdcdata.

ENDFORM. " bdc_transaction1

*----


*

Former Member
0 Kudos

Hi Charlene

Please check after making below highlighted changes.

**---------------------------------------------------------------**
DATA: BEGIN OF it_display OCCURS 0,
  fkart LIKE RV60A-FKART,
  vbeln LIKE vbrk-vbeln,
END OF it_display.
**---------------------------------------------------------------**
**---------------------------------------------------------------**
IF VBRK-VKORG EQ '9083' AND ( VBRK-KONDA EQ 'Y1' OR VBRK-KONDA EQ 'Y2' ) . "sales org and price group must fit criteria
       PERFORM get_data.
       PERFORM bdc_posting.
  	message S003(z000).
ELSE.
	message S004(z000).   		
ENDIF.
**---------------------------------------------------------------**
**---------------------------------------------------------------**
FORM bdc_posting.

  LOOP AT it_display.

    PERFORM bdc_open.

<b>*      BDCDATA-PROGRAM   = 'SAPMV60A'.
*      BDCDATA-DYNPRO    = '0102'.
*      BDCDATA-DYNBEGIN  = 'X'.
*      BDCDATA-FNAM      = 'BDC_CURSOR'.
*      BDCDATA-FVAL      = 'KOMFK-VBELN'.
*      BDCDATA-FNAM      = 'BDC_OKCODE'.
*      BDCDATA-FVAL      = '/00'.
*      BDCDATA-FNAM      = 'RV60A-FKART'.           "billing type
*      BDCDATA-FVAL      = 'YG2'.
*      BDCDATA-FNAM      = 'KOMFK-VBELN'.           "SD document number
*      BDCDATA-FVAL      = it_display-vbeln.
*
*      BDCDATA-PROGRAM   = 'SAPMV60A'.
*      BDCDATA-DYNPRO    = '0103'.
*      BDCDATA-DYNBEGIN  = 'X'.
*      BDCDATA-FNAM      = 'BDC_CURSOR'.
*      BDCDATA-FVAL      = '*TVFKT-VTEXT(01)'.
*      BDCDATA-FNAM      = 'BDC_OKCODE'.
*      BDCDATA-FVAL      = '=SICH'.
       perform bdc_dynpro      using 'SAPMV60A' '0102'.
       perform bdc_field       using 'BDC_CURSOR'
                               'KOMFK-VBELN(01)'.
       perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
       perform bdc_field       using 'RV60A-FKART'
                              'YG2'.
       perform bdc_field       using 'KOMFK-VBELN(01)'
                               it_display-vbeln.
       perform bdc_dynpro      using 'SAPMV60A' '0104'.
       perform bdc_field       using 'BDC_CURSOR'
                               'VBRK-FKART'.
       perform bdc_field       using 'BDC_OKCODE'
                              '=SICH'.</b>

       PERFORM bdc_transaction1 USING 'ZVF01'.

    CALL FUNCTION 'BDC_CLOSE_GROUP'.

  ENDLOOP.

ENDFORM.
**---------------------------------------------------------------**
**---------------------------------------------------------------**
FORM get_data.
  MOVE: vbrk-vbeln TO it_display-vbeln.
  APPEND it_display.
ENDFORM.	"get_data

FORM bdc_open .
  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      client = sy-mandt
      group  = 'M__MATGRLOAD'
      user   = SY-UNAME
      keep   = 'X'.
ENDFORM.                    " bdc_open

FORM bdc_transaction1 USING tcode.
  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      tcode     = <b>tcode "'ZVF01'</b>
    TABLES
      dynprotab = bdcdata.
ENDFORM.                    " bdc_transaction1

<b>FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCDATA.
  BDCDATA-PROGRAM  = PROGRAM.
  BDCDATA-DYNPRO   = DYNPRO.
  BDCDATA-DYNBEGIN = 'X'.
  APPEND BDCDATA.
ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.
  IF FVAL <> SPACE.
    CLEAR BDCDATA.
    BDCDATA-FNAM = FNAM.
    BDCDATA-FVAL = FVAL.
    APPEND BDCDATA.
  ENDIF.
ENDFORM.</b>

Also note that as you are using normal process, you can directly use normal transaction VF01.

Kind Regards

Eswar

Former Member
0 Kudos

Thanks! I managed to get past CALL FUNCTION 'BDC_OPEN_GROUP'.

However im stuck with this now BDC_INSERT now...error:

BDC_INSERT, screen .&. is invalid

What do i do when i hit error with CALL FUNCTION 'BDC_CLOSE_GROUP' as well?

Help much appreciated. Thank you.

Former Member
0 Kudos

HI Charlene

Can you post your code???

Kind Regards

Eswar

Former Member
0 Kudos

Hi,

pass sy-uname and user name shouls be maintained in

user master table USR01

CALL FUNCTION 'BDC_OPEN_GROUP' " Not needed for Call Transaction

EXPORTING " Used to handle Errors.

GROUP = 'M__MATGRLOAD'

USER = SY-UNAME

KEEP = 'X'.

Regards

amole

Former Member
0 Kudos

Thanks for all the answers.

Okay...i created the BDC as suggested...

when i put in the function 'BDC_OPEN_GROUP' i hit this error

BDC_OPEN_GROUP, user .. is invalid

I cant move past this point.

Former Member
0 Kudos

perform bdc_dynpro using 'SAPMV60A' '0102'.

perform bdc_field using 'BDC_CURSOR'

'RV60A-FKART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

<b>perform bdc_field using 'RV60A-FKART'

'YGT'.</b>

perform bdc_dynpro using 'SAPMV60A' '0102'.

perform bdc_field using 'BDC_CURSOR'

'KOMFK-VBELN(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

<b>perform bdc_field using 'RV60A-FKART'

'YGT'.</b>

shishupalreddy
Active Contributor
0 Kudos

hAI

use the following code for BDC .

perform bdc_dynpro using 'SAPMV60A' '0102'.

perform bdc_field using 'BDC_CURSOR'

'KOMFK-VBELN(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'RV60A-FKART'

'YG2'.

perform bdc_field using 'KOMFK-VBELN(01)'

<DOCUMNET NUMBER>'343434343'.

Regards

Former Member
0 Kudos

HI Charlene

As the billing document type doesnt have Paramter-ID, you can try this way:

Create a ZVF01 transaction with the following steps:

1. SE93

2. Transction Name: ZVF01.

3. Select the type as Parameter Transaction

4. In the next screen, give transaction name as VF01.

5. Scroll down to last for default values: give field as "RV60A-FKART" and value as 'YG2'.

6. Save. Now try executing the same to check that YG2 is fixex in your screen.

7. Now in your BDC, call ZVF01 with document number.

The billing type will be YG2 irrespective of online or background execution of ZVF01.

This should help solve your case.

Kind Regards

Eswar

Former Member
0 Kudos

Hi,

do recording in shdb on VF01 by inputing

billing type and document no.

for test purpose pick up document no from vbrk field

with billing type = 'YG2' and do recording

Regards

Amole

Former Member
0 Kudos

While recording itself ,

do the recording with YG2 value in ur screen .

in the program

just

SAPMV60A 0102 X

BDC_CURSOR RV60A-FKART

BDC_OKCODE /00

RV60A-FKART 'YGT'

maintain this in ur program

regards,

VIjay