0% found this document useful (0 votes)
6 views2 pages

Exc Rate

The document contains an ABAP code snippet that checks the transaction code and billing type to determine the exchange rate for a specific condition (YREX). It retrieves the delivery and sales order information to obtain the exchange rate if certain conditions are met; otherwise, it falls back to existing logic to read the exchange rate. The code ensures that the correct currency rates are assigned based on the billing date and foreign currency.

Uploaded by

gaurav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Exc Rate

The document contains an ABAP code snippet that checks the transaction code and billing type to determine the exchange rate for a specific condition (YREX). It retrieves the delivery and sales order information to obtain the exchange rate if certain conditions are met; otherwise, it falls back to existing logic to read the exchange rate. The code ensures that the correct currency rates are assigned based on the billing date and foreign currency.

Uploaded by

gaurav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

IF sy-tcode EQ 'VF01'.

IF vbrk-vtweg = '21'.

"🔥 NEW CONDITION FOR YREX

IF vbrk-fkart = 'YREX'.

DATA: lv_vbeln TYPE vbeln_va,

lv_kursk TYPE vbak-kursk.

" Step 1: Billing -> Delivery

SELECT SINGLE vbelv INTO @DATA(lv_del)

FROM vbfa

WHERE vbeln = @vbrk-vbeln

AND vbtyp_n = 'J'. "Delivery

IF sy-subrc = 0.

" Step 2: Delivery -> Sales Order

SELECT SINGLE vbelv INTO lv_vbeln

FROM vbfa

WHERE vbeln = @lv_del

AND vbtyp_n = 'C'. "Sales Order

IF sy-subrc = 0.

" Step 3: Get Exchange Rate from SO

SELECT SINGLE kursk INTO lv_kursk

FROM vbak

WHERE vbeln = @lv_vbeln.

IF sy-subrc = 0 AND lv_kursk IS NOT INITIAL.

vbrk-kurrf = vbkd-kursk = lv_kursk.

ENDIF.

ENDIF.

ENDIF.

ELSE.

"👉 EXISTING LOGIC SAME RAKH

CLEAR : vbrk-kurrf , vbkd-kursk .


CALL FUNCTION 'READ_EXCHANGE_RATE'

EXPORTING

date = vbrk-fkdat

foreign_currency = vbrk-waerk

local_currency = 'INR'

type_of_rate = 'E'

IMPORTING

valid_from_date = DATA(valid_from_date).

SELECT gdatu, ukurs FROM tcurr

INTO TABLE @DATA(lt_curr)

WHERE kurst = 'E'

AND fcurr = @vbrk-waerk

ORDER BY gdatu ASCENDING.

READ TABLE lt_curr INTO DATA(ls_data) INDEX 1.

IF sy-subrc EQ 0.

vbrk-kurrf = vbkd-kursk = ls_data-ukurs.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

You might also like