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 Problem

Former Member
0 Likes
669

Dear Guru,

Here i have encountered a typical issue.

Im Performing BDC for VK11 (Create Condition Record) with "Key Combination" --->> "Location, Material Code (Base Price for Longs)".

While I am running this BDC ( source code attached below) in All screen mode every datas which are of type "CHAR" like--->>

Condition type(kschl) ,

Plant(werks) ,

Material No(matnr),

Valid From date(datab),

Valid To date(datbi),

Rate Unit(konwa) are coming properly from flatfile except

Rate (condition amount - KBETR) which is are of data type "CURR".

So guru I want to know what code i should add into my below bdc prog to fetch data properly into RATE - Condition amount field which is of type " CURR".

Pls Help.

Source Code:

REPORT z_bdc_vk11_famd

NO STANDARD PAGE HEADING LINE-SIZE 255.

&----


*& DATA-DECLARATION

&----


TYPES: BEGIN OF t_cust,

kschl LIKE rv13a-kschl,

werks LIKE komg-werks,

matnr LIKE komg-matnr,

kbetr LIKE konp-kbetr,

      • konwa LIKE konp-konwa,

datab LIKE rv13a-datab,

datbi LIKE rv13a-datbi,

END OF t_cust.

TYPES: BEGIN OF t_sucrec,

cnum TYPE komg-werks,

cnam TYPE komg-matnr,

END OF t_sucrec.

TYPES: BEGIN OF t_errrec,

lineno TYPE string, "Line Number

message TYPE string, "Error Message

END OF t_errrec.

DATA: v_file TYPE string, "Variable for storing flat file

it_cust TYPE STANDARD TABLE OF t_cust, "Internal table of Customer

wa_cust LIKE LINE OF it_cust, "Workarea of Internal table it_cust

it_sucrec TYPE STANDARD TABLE OF t_sucrec,

"Internal table of Success records

wa_sucrec LIKE LINE OF it_sucrec,

"Workarea of Internal table it_sucrec

it_errrec TYPE STANDARD TABLE OF t_errrec,

"Internal table of Error records

wa_errrec LIKE LINE OF it_errrec,

"Workarea of Internal table it_errrec

it_bdctab LIKE bdcdata OCCURS 0 WITH HEADER LINE,

"Internal table structure of BDCDATA

it_messagetab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

"Tracing Error Messages

v_date LIKE sy-datum, "Controlling of session date

v_index LIKE sy-tabix, "Index Number

v_totrec TYPE i, "Total Records

v_errrec TYPE i, "Error Records

v_sucrec TYPE i, "Success Records

v_sesschk TYPE c. "Session maintenance

&----


*& SELECTION-SCREEN

&----


SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001 NO

INTERVALS.

PARAMETERS: p_file TYPE rlgrap-filename.

"rlgrap-filename is a predefined structure

SELECTION-SCREEN: END OF BLOCK blk1.

SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002 NO

INTERVALS.

PARAMETERS: p_mode LIKE ctu_params-dismode DEFAULT 'N',

p_update LIKE ctu_params-updmode DEFAULT 'A'.

SELECTION-SCREEN END OF BLOCK blk2.

&----


*& INITIALIZATION

&----


INITIALIZATION.

v_date = sy-datum - 1.

&----


*& AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file

&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

IMPORTING

file_name = p_file.

&----


*& START-OF-SELECTION

&----


START-OF-SELECTION.

v_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_cust

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc = 0.

****MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

        • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

&----


*& END-OF-SELECTION

&----


END-OF-SELECTION.

LOOP AT it_cust INTO wa_cust.

v_index = sy-tabix.

PERFORM bdc_dynpro USING 'SAPMV13A' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV13A-KSCHL'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ANTA'.

PERFORM bdc_field USING 'RV13A-KSCHL'

wa_cust-kschl.

PERFORM bdc_dynpro USING 'SAPLV14A' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV130-SELKZ(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=WEIT'.

PERFORM bdc_dynpro USING 'SAPMV13A' '1595'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV13A-DATBI(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'KOMG-WERKS'

wa_cust-werks.

PERFORM bdc_field USING 'KOMG-MATNR(01)'

wa_cust-matnr.

PERFORM bdc_field USING 'KONP-KBETR(01)'

wa_cust-kbetr.

PERFORM bdc_field USING 'KONP-KONWA(01)'

'INR'.

PERFORM bdc_field USING 'RV13A-DATAB(01)'

wa_cust-datab.

PERFORM bdc_field USING 'RV13A-DATBI(01)'

wa_cust-datbi.

PERFORM bdc_dynpro USING 'SAPMV13A' '1595'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KOMG-MATNR(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SICH'.

CALL TRANSACTION 'VK11' USING it_bdctab

MODE p_mode

UPDATE p_update

MESSAGES INTO it_messagetab.

IF sy-subrc = 0.

&----


*& reading success records to corresponding internal table

&----


READ TABLE it_messagetab WITH KEY msgtyp = 'S'.

IF sy-subrc = 0.

  • wa_sucrec-cnum = it_messagetab-msgv1.

wa_sucrec-cnum = wa_cust-werks.

wa_sucrec-cnam = wa_cust-matnr.

APPEND wa_sucrec TO it_sucrec.

CLEAR wa_sucrec.

ENDIF.

ELSE.

&----


*& reading error records to corresponding internal table

&----


READ TABLE it_messagetab WITH KEY msgtyp = 'E'.

IF sy-subrc = 0.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = sy-msgid

no = it_messagetab-msgnr

v1 = it_messagetab-msgv1

v2 = it_messagetab-msgv2

v3 = it_messagetab-msgv3

v4 = it_messagetab-msgv4

IMPORTING

msg = wa_errrec-message.

wa_errrec-lineno = v_index.

APPEND wa_errrec TO it_errrec.

CLEAR wa_errrec.

ENDIF.

ENDIF.

CLEAR : it_bdctab, it_messagetab.

REFRESH: it_bdctab, it_messagetab.

ENDLOOP.

DESCRIBE TABLE it_cust LINES v_totrec.

DESCRIBE TABLE it_errrec LINES v_errrec.

DESCRIBE TABLE it_sucrec LINES v_sucrec.

PERFORM disp_data.

SKIP 2.

IF v_sucrec > 0.

PERFORM disp_success_data.

ENDIF.

SKIP 2.

IF v_errrec > 0.

PERFORM disp_error_data.

ENDIF.

&----


*& Form bdc_dynpro

&----


    1. text

----


    1. -->P_0104 text

    2. -->P_0105 text

----


FORM bdc_dynpro USING program dynpro.

CLEAR it_bdctab.

it_bdctab-program = program.

it_bdctab-dynpro = dynpro.

it_bdctab-dynbegin = 'X'.

APPEND it_bdctab.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


FORM bdc_field USING fnam fval.

CLEAR it_bdctab.

it_bdctab-fnam = fnam.

it_bdctab-fval = fval.

APPEND it_bdctab.

ENDFORM. " bdc_field

&----


*& Form disp_data

&----


FORM disp_data .

ULINE (45).

WRITE : / sy-vline,

4 'FAMD Price Master UPDATE SUMMARY'(004) COLOR 1,

45 sy-vline.

ULINE /(45).

WRITE : / sy-vline,

'Total Records Processed'(007),

28 '=',

30 v_totrec,

45 sy-vline,

/ sy-vline,

'Error Records'(005),

28 '=',

30 v_errrec,

45 sy-vline,

/ sy-vline,

'Successful Records'(006),

28 '=',

30 v_sucrec,

45 sy-vline.

ULINE /(45).

ENDFORM. " disp_data

&----


*& Form disp_success_data

&----


FORM disp_success_data .

ULINE (45).

WRITE : / sy-vline,

14 'Successful Records'(012) COLOR 1,

45 sy-vline.

ULINE /(45).

WRITE : / sy-vline ,

'Plant Number'(010) COLOR 2,

17 sy-vline,

25 'Material Number'(011) COLOR 2,

45 sy-vline.

ULINE /(45).

LOOP AT it_sucrec INTO wa_sucrec.

WRITE: / sy-vline ,

wa_sucrec-cnum,

17 sy-vline,

19 wa_sucrec-cnam,

45 sy-vline.

ENDLOOP.

ULINE /(45).

ENDFORM. " disp_success_data

&----


*& Form disp_error_data

&----


FORM disp_error_data .

ULINE (90).

WRITE : / sy-vline,

35 'Error Records'(013) COLOR 1,

90 sy-vline.

ULINE /(90).

WRITE : / sy-vline,

'Record Number'(008) COLOR 2,

sy-vline,

37 'Reason for error'(009) COLOR 2,

90 sy-vline.

ULINE /(90).

LOOP AT it_errrec INTO wa_errrec.

WRITE : / sy-vline,

wa_errrec-lineno,

17 sy-vline,

wa_errrec-message,

90 sy-vline.

ENDLOOP.

ULINE /(90).

ENDFORM. " disp_error_data

Flat file Sequence:

Condition Type Plant Matrial No Rate Validity start date Validity end date

1 ACCEPTED SOLUTION
Read only

former_member784222
Active Participant
0 Likes
575

Hi,

I think you are using 'wa_cust-kbetr' directly while populating rate field in BDC.

Please write wa_cust-kbetr into a character variable and pass the character variable to BDC.

data: t_rate(16) type c.

write wa_cust-kbetr to t_rate no-grouping.

Pass t_rate instead of wa_cust-kbetr in the BDC.

PERFORM bdc_field USING 'KONP-KBETR(01)'

t_rate.

Like wise you might have to write your date variables also.

Thanks and regards,

S. Chandramouli.

3 REPLIES 3
Read only

former_member784222
Active Participant
0 Likes
576

Hi,

I think you are using 'wa_cust-kbetr' directly while populating rate field in BDC.

Please write wa_cust-kbetr into a character variable and pass the character variable to BDC.

data: t_rate(16) type c.

write wa_cust-kbetr to t_rate no-grouping.

Pass t_rate instead of wa_cust-kbetr in the BDC.

PERFORM bdc_field USING 'KONP-KBETR(01)'

t_rate.

Like wise you might have to write your date variables also.

Thanks and regards,

S. Chandramouli.

Read only

0 Likes
575

Thnx for ur precious suggestion sir, I will try it n will giv u feed back after that...

Read only

0 Likes
575

Yess sirr it worked out.

Thanks a lot for your kind response.

I hav rewarded max point to you.

Thnx a lot.