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 display Error while converting the Currency ..

Former Member
0 Likes
621

Hi,

Using BDC i have to cal Transaction Vk15.

In this we have a field KONP-kbetr, which is a currency feild, with 2 decimals.

I have to converted the Currency to 'EUR' and has moved it in a variable "gv_char13".

______________+declaration part+_____________________
Data :  gv_eurconv_vk(14)      TYPE rkb1k-exchr,
           gv_eurconv_vk       TYPE konp-kbetr,
             gv_char13(14) TYPE c.
_____________+Currency Conversion+________________
  CALL FUNCTION 'RKC_SINGLE_EXCHANGE_RATE_GET'
    EXPORTING
      datum               = gv_sydatum
      kurst               = 'P'
      ncurr               = 'EUR'
      vcurr               = 'CZK'
 IMPORTING
   exchr               = gv_exchr_vk
   EXCEPTIONS
     no_rate_found       = 1
     OTHERS              = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  WRITE gv_exchr_vk  NO-GROUPING CURRENCY 'EUR'.
  MOVE gv_exchr_vk TO gv_eurconv_vk.
  CLEAR gv_char13.
  WRITE gv_eurconv_vk TO gv_char13.
_________+Passing Value IN BDC VK15+__________
 
    wa_bdcdata_vk-fnam     = 'KONP-KBETR(01)'.
    wa_bdcdata_vk-fval     =  gv_char13.                      
    SHIFT  wa_bdcdata_vk-fval LEFT DELETING LEADING space.
    APPEND wa_bdcdata_vk TO gt_bdcdata_vk.
    CLEAR wa_bdcdata_vk.
----------+Calling the Transaction VK15+____
  CALL TRANSACTION 'VK15' USING gt_bdcdata_vk  MODE 'E' MESSAGES INTO gt_bdcmsg_vk.
**--Display the error message if the call transaction fails--**
    IF sy-subrc EQ 0.
      IF NOT gt_bdcmsg_vk IS INITIAL.
        READ TABLE gt_bdcmsg_vk INTO wa_bdcmsg_vk INDEX sy-index.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id     = wa_bdcmsg_vk-msgid
            lang   = 'EN'
            no     = wa_bdcmsg_vk-msgnr
            v1     = wa_bdcmsg_vk-msgv1
            v2     = wa_bdcmsg_vk-msgv2
            v3     = wa_bdcmsg_vk-msgv3
            v4     = wa_bdcmsg_vk-msgv4
          IMPORTING
            msg    = gv_text_vk
          EXCEPTIONS
            OTHERS = 0.
        IF sy-subrc EQ 0.
          APPEND  gv_text_vk TO gt_mess_vk.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
**--Display the error message on the screen--**
  IF NOT gt_mess_vk[] IS INITIAL.
    LOOP AT gt_mess_vk INTO wa_mess_vk.
      WRITE:/ wa_mess_vk.
      CLEAR wa_mess_vk.
    ENDLOOP.
  ENDIF.

In the dispaly tabkle for error message "gt_bdcmsg_vk" we get the sucess message and in table "gt_mess_vk" we get the message as the "Condition records Saved."

The problem is when this report is executed it displayes the converted currency Value and in next line it dispalyes the ""Condition records Saved".

But idealy the converted currency value should not be dispalyed.

Actual Sample display:(shuld be this 😞

-


xyz.. message

Condition Record Saved.

Sample display (Error Dispaly 😞

-


xyz.. message

3,14E-02 -


(This shuold not be dispalyed)

Condition Record Saved.

1 ACCEPTED SOLUTION
Read only

former_member210123
Active Participant
0 Likes
505

The message u require will be in one of the

v1 = wa_bdcmsg_vk-msgv1

v2 = wa_bdcmsg_vk-msgv2

v3 = wa_bdcmsg_vk-msgv3

v4 = wa_bdcmsg_vk-msgv4.

Find that out and use that instead u will not get problems.

2 REPLIES 2
Read only

former_member210123
Active Participant
0 Likes
506

The message u require will be in one of the

v1 = wa_bdcmsg_vk-msgv1

v2 = wa_bdcmsg_vk-msgv2

v3 = wa_bdcmsg_vk-msgv3

v4 = wa_bdcmsg_vk-msgv4.

Find that out and use that instead u will not get problems.

Read only

Former Member
0 Likes
505

Use modified code...

*______________declaration part_____________________

Data : gv_eurconv_vk(14) TYPE rkb1k-exchr,

    • gv_eurconv_vk TYPE konp-kbetr,

gv_eurconv_vk TYPE p DECIMALS 2,

gv_char13(14) TYPE c.

*_____________Currency Conversion________________

CALL FUNCTION 'RKC_SINGLE_EXCHANGE_RATE_GET'

EXPORTING

datum = gv_sydatum

kurst = 'P'

ncurr = 'EUR'

vcurr = 'CZK'

IMPORTING

exchr = gv_exchr_vk

EXCEPTIONS

no_rate_found = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

    • WRITE gv_exchr_vk NO-GROUPING CURRENCY 'EUR'.

    • MOVE gv_exchr_vk TO gv_eurconv_vk.

gv_eurconv_vk = gv_exchr_vk.

CLEAR gv_char13.

WRITE gv_eurconv_vk TO gv_char13.

*_________Passing Value IN BDC VK15__________

wa_bdcdata_vk-fnam = 'KONP-KBETR(01)'.

wa_bdcdata_vk-fval = gv_char13.

SHIFT wa_bdcdata_vk-fval LEFT DELETING LEADING space.

APPEND wa_bdcdata_vk TO gt_bdcdata_vk.

CLEAR wa_bdcdata_vk.

*----


Calling the Transaction VK15____

CALL TRANSACTION 'VK15' USING gt_bdcdata_vk MODE 'E' MESSAGES INTO gt_bdcmsg_vk.

*Display the error message if the call transaction fails*

IF sy-subrc EQ 0.

IF NOT gt_bdcmsg_vk IS INITIAL.

READ TABLE gt_bdcmsg_vk INTO wa_bdcmsg_vk INDEX sy-index.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = wa_bdcmsg_vk-msgid

lang = 'EN'

no = wa_bdcmsg_vk-msgnr

v1 = wa_bdcmsg_vk-msgv1

v2 = wa_bdcmsg_vk-msgv2

v3 = wa_bdcmsg_vk-msgv3

v4 = wa_bdcmsg_vk-msgv4

IMPORTING

msg = gv_text_vk

EXCEPTIONS

OTHERS = 0.

IF sy-subrc EQ 0.

APPEND gv_text_vk TO gt_mess_vk.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

*Display the error message on the screen*

IF NOT gt_mess_vk[] IS INITIAL.

LOOP AT gt_mess_vk INTO wa_mess_vk.

WRITE:/ wa_mess_vk.

CLEAR wa_mess_vk.

ENDLOOP.

ENDIF.