Convert_to_local_currency
hi all,
i need some clarification with regarding the function module convert_to_local_currency.
i have a requirement to convert form USD to GBP currency in my program so what are the data types i have to declare, how to pass parameters, are there any calculations i need to do please help me out with an example to get me clear idea. Thanks in advance.
hi
here some code:
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SYST-DATUM
FOREIGN_AMOUNT = for_amount
FOREIGN_CURRENCY = 'USD'
LOCAL_CURRENCY = 'GPP'
TYPE_OF_RATE = 'M'
IMPORTING
LOCAL_AMOUNT = loc_ammount
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5.
The call calculates the "GPP" value of a given "USD" value based on TCURR's 'official averadge rate' of the current day. Sorry, I just translated the german term, but this is the rate, that is used for international money transfer.
Pls. remember that someone has to fill TCURR with correct values
<i>chk another code.</i>
<b>chk the bold part , u will get the data type of parametsrs</b>
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = 001
DATE =<b> sy-datum</b>
FOREIGN_CURRENCY = <b>wa1-WAERS</b> " here you need to declare your foreign currency i.e USD
LOCAL_CURRENCY = <b>TCURR-FCURR</b>
FOREIGN_AMOUNT = <b>wa1-DMBTR</b> " here you need to declare your amount field.
RATE = <b>tcurr-ukurs</b>
TYPE_OF_RATE = 'M' " check this also the average rate
READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE = <b>tcurr-UKURS</b>
FOREIGN_FACTOR =
LOCAL_AMOUNT = wa1-TOTAL " this is the field where the converted amt has to be displayed.
LOCAL_FACTOR =
EXCHANGE_RATEX =
FIXED_RATE =
DERIVED_RATE_TYPE =
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
If you find my answer useful, please don't forget the reward.
rgds
anvcer
Message was edited by: Anversha s
Similar Messages
-
URGENT : CONVERT_TO_LOCAL_CURRENCY
Hi Experts,
while using the function module CONVERT_TO_LOCAL_CURRENCY in the report.
when executing the report it showing the error
the error is showing in popup like this
Translation Result
101,913,673,676,50 USD is too long ..
please kindly do favor for me ...
programm.......
TABLES: zzsvendor, zzaddress, zzkioskact, zwf_upi, zzcnames,
t005, t005s, lfa1, t024e, zzfinsum, zzinsur, t059q, bnka, ekpo,t023t,
adrc, adr6.
DATA: BEGIN OF lt_summary OCCURS 0,
appno TYPE zzsvendor-appno,
vendor TYPE zzsvendor-vendor,
vendorname TYPE lfa1-name1,
reqdt TYPE zzkioskact-reqdt,
ismbe TYPE zzsvendor-ismbe,
iswbe TYPE zzsvendor-iswbe,
isdbe TYPE zzsvendor-isdbe,
street TYPE adrc-street,
str_suppl3 TYPE adrc-str_suppl3,
city1 TYPE adrc-city1,
city2 TYPE adrc-city2,
region TYPE adrc-region,
post_code1 TYPE adrc-post_code1,
country TYPE adrc-country,
tel_number TYPE adrc-tel_number,
fax_number TYPE adrc-fax_number,
smtp_addr TYPE adr6-smtp_addr,
pcat1 TYPE zzsvendor-pcat1,
pcat2 TYPE zzsvendor-pcat2,
pcat3 TYPE zzsvendor-pcat3,
po TYPE ekko-konnr,
povalue TYPE ekpo-netwr,
END OF lt_summary.
DATA: BEGIN OF lt_zzsvendor OCCURS 0,
appno TYPE zzsvendor-appno,
vendor TYPE zzsvendor-vendor,
vendorname TYPE lfa1-name1,
ismbe TYPE zzsvendor-ismbe,
iswbe TYPE zzsvendor-iswbe,
isdbe TYPE zzsvendor-isdbe,
pcat1 TYPE zzsvendor-pcat1,
pcat2 TYPE zzsvendor-pcat2,
pcat3 TYPE zzsvendor-pcat3,
END OF lt_zzsvendor.
DATA: lt_zzkioskact LIKE zzkioskact OCCURS 0 WITH HEADER LINE,
*Begin of changes by wb328936
lt_ekko LIKE ekko OCCURS 0 WITH HEADER LINE,
lt_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF mlist,
appno TYPE zzsvendor-appno,
vendor TYPE zzsvendor-vendor,
vendorname TYPE lfa1-name1,
reqdt TYPE zzkioskact-reqdt,
ismbe TYPE zzsvendor-ismbe,
iswbe TYPE zzsvendor-iswbe,
isdbe TYPE zzsvendor-isdbe,
street TYPE adrc-street,
str_suppl3 TYPE adrc-str_suppl3,
city1 TYPE adrc-city1,
city2 TYPE adrc-city2,
region TYPE adrc-region,
post_code1 TYPE adrc-post_code1,
country TYPE adrc-country,
tel_number TYPE adrc-tel_number,
fax_number TYPE adrc-fax_number,
smtp_addr TYPE adr6-smtp_addr,
pcat1 TYPE zzsvendor-pcat1,
pcat2 TYPE zzsvendor-pcat2,
pcat3 TYPE zzsvendor-pcat3,
po TYPE ekko-konnr,
povalue TYPE ekko-rlwrt,
povalue TYPE ekpo-netwr,
*End of changes by wb328936
END OF mlist,
mtlist LIKE mlist OCCURS 0.
DATA: lv_name1 TYPE lfa1-name1,
lv_adrnr TYPE lfa1-adrnr,
lv_email TYPE adr6-smtp_addr,
lv_street TYPE adrc-street,
lv_str_suppl3 TYPE adrc-str_suppl3,
lv_city1 TYPE adrc-city1,
lv_city2 TYPE adrc-city2,
lv_region TYPE adrc-region,
lv_post_code1 TYPE adrc-post_code1,
lv_country TYPE adrc-country,
lv_tel_number TYPE adrc-tel_number,
lv_fax_number TYPE adrc-fax_number,
delimiter(1) VALUE ' ',
lv_matg_code1 TYPE zzsvendor-pcat1,
lv_matg_name1 TYPE zzsvendor-pcat1,
lv_matg_code2 TYPE zzsvendor-pcat1,
lv_matg_name2 TYPE zzsvendor-pcat1,
lv_matg_code3 TYPE zzsvendor-pcat1,
lv_matg_name3 TYPE zzsvendor-pcat1,
lv_desc1 TYPE t023t-wgbez60,
lv_desc2 TYPE t023t-wgbez60,
lv_desc3 TYPE t023t-wgbez60,
lv_pcat1 TYPE zzpcat,
lv_pcat2 TYPE zzpcat,
lv_pcat3 TYPE zzpcat,
lv_count TYPE i,
lv_amt TYPE ekko-rlwrt.
lv_total_amt TYPE ekpo-netwr,
lv_amt TYPE ekpo-netwr.
*End of changes by wb328936
SELECTION-SCREEN BEGIN OF BLOCK date WITH FRAME TITLE text-023.
SELECT-OPTIONS s_date FOR zzkioskact-reqdt.
SELECTION-SCREEN END OF BLOCK date.
Checkboxes for MBE, WBE, and DBE status
SELECTION-SCREEN BEGIN OF BLOCK status WITH FRAME TITLE text-024.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_mbe AS CHECKBOX.
SELECTION-SCREEN COMMENT (31) text-080 .
PARAMETER p_wbe AS CHECKBOX.
SELECTION-SCREEN COMMENT (28) text-081.
PARAMETER p_dbe AS CHECKBOX.
SELECTION-SCREEN COMMENT (31) text-082 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK status.
SELECTION-SCREEN BEGIN OF BLOCK appno WITH FRAME TITLE text-025.
SELECT-OPTIONS s_appno FOR zzsvendor-appno MATCHCODE OBJECT zapp.
SELECTION-SCREEN END OF BLOCK appno.
SELECTION-SCREEN BEGIN OF BLOCK vendor WITH FRAME TITLE text-011.
SELECT-OPTIONS s_vendor FOR zzsvendor-vendor MATCHCODE OBJECT zven.
SELECTION-SCREEN END OF BLOCK vendor.
Material Group
SELECTION-SCREEN BEGIN OF BLOCK matgroup WITH FRAME TITLE text-083.
SELECT-OPTIONS s_matgrp FOR zzsvendor-pcat1.
SELECTION-SCREEN END OF BLOCK matgroup.
*Begin of changes by wb328936
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 12.
PARAMETER p_pos AS CHECKBOX.
SELECTION-SCREEN COMMENT 2(10) text-102.
SELECTION-SCREEN END OF LINE.
INCLUDE zalv_selection.
START-OF-SELECTION.
IF p_mbe IS INITIAL AND p_wbe IS INITIAL AND p_dbe IS INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS NOT INITIAL AND p_wbe IS INITIAL AND p_dbe IS INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ismbe EQ p_mbe AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS NOT INITIAL AND p_wbe IS NOT INITIAL AND p_dbe IS INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ( ismbe EQ p_mbe OR iswbe EQ p_wbe ) AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS NOT INITIAL AND p_wbe IS NOT INITIAL AND
p_dbe IS NOT INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ( ismbe EQ p_mbe OR iswbe EQ p_wbe OR isdbe EQ p_dbe ) AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS INITIAL AND p_wbe IS INITIAL AND
p_dbe IS NOT INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ( isdbe EQ p_dbe ) AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS INITIAL AND p_wbe IS NOT INITIAL AND
p_dbe IS NOT INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ( iswbe EQ p_wbe OR isdbe EQ p_dbe ) AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS INITIAL AND p_wbe IS NOT INITIAL AND
p_dbe IS INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE iswbe EQ p_wbe AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
IF p_mbe IS NOT INITIAL AND p_wbe IS INITIAL AND
p_dbe IS NOT INITIAL.
SELECT appno vendor ismbe iswbe isdbe pcat1 pcat2 pcat3
INTO CORRESPONDING FIELDS OF TABLE lt_zzsvendor
FROM zzsvendor
WHERE ( ismbe EQ p_mbe OR isdbe EQ p_dbe ) AND
vendor IN s_vendor AND
appno IN s_appno.
ENDIF.
REFRESH lt_summary.
LOOP AT lt_zzsvendor.
SELECT * FROM zzkioskact WHERE appno = lt_zzsvendor-appno
AND srno = '0000000001'.
ENDSELECT.
IF p_pos EQ 'X'.
CLEAR : lt_ekko, lt_ekpo, lv_count, lv_amt, lv_total_amt.
REFRESH : lt_ekko, lt_ekpo.
SELECT * FROM ekko INTO TABLE lt_ekko WHERE lifnr = lt_zzsvendor-vendor.
DESCRIBE TABLE lt_ekko LINES lv_count.
IF lv_count = 0.
lv_total_amt = 0.
ELSE.
LOOP AT lt_ekko.
SELECT * FROM ekpo INTO TABLE lt_ekpo WHERE ebeln = lt_ekko-ebeln.
LOOP AT lt_ekpo.
lv_total_amt = lv_total_amt + lt_ekpo-netwr.
ENDLOOP.
IF lt_ekko-waers <> 'USD'.
CLEAR lv_amt.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
DATE = SY-DATUM
FOREIGN_AMOUNT = lv_total_amt
FOREIGN_CURRENCY = lt_ekko-waers
LOCAL_CURRENCY = 'USD'
RATE = 0
TYPE_OF_RATE = 'M'
READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE =
FOREIGN_FACTOR =
LOCAL_AMOUNT = lv_amt
LOCAL_FACTOR =
EXCHANGE_RATEX =
FIXED_RATE =
DERIVED_RATE_TYPE =
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6
IF SY-SUBRC = 0.
lv_total_amt = lv_amt.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
IF zzkioskact-reqdt IN s_date.
SPLIT lt_zzsvendor-pcat1 AT delimiter
INTO lv_matg_code1 lv_matg_name1.
SPLIT lt_zzsvendor-pcat2 AT delimiter
INTO lv_matg_code2 lv_matg_name2.
SPLIT lt_zzsvendor-pcat3 AT delimiter
INTO lv_matg_code3 lv_matg_name3.
CLEAR : lv_desc1,lv_desc2,lv_desc3,lv_pcat1,lv_pcat2,lv_pcat3.
SELECT SINGLE wgbez60 FROM t023t INTO lv_desc1
WHERE spras = 'E'
AND matkl = lv_matg_code1.
IF sy-subrc EQ 0.
CONCATENATE lv_matg_code1 lv_desc1 INTO lv_pcat1 SEPARATED BY '-'.
ENDIF.
SELECT SINGLE wgbez60 FROM t023t INTO lv_desc2
WHERE spras = 'E'
AND matkl = lv_matg_code2.
IF sy-subrc EQ 0.
CONCATENATE lv_matg_code2 lv_desc2 INTO lv_pcat2 SEPARATED BY '-'.
ENDIF.
SELECT SINGLE wgbez60 FROM t023t INTO lv_desc3
WHERE spras = 'E'
AND matkl = lv_matg_code3.
IF sy-subrc EQ 0.
CONCATENATE lv_matg_code3 lv_desc3 INTO lv_pcat3 SEPARATED BY '-'.
ENDIF.
IF ( lv_matg_code1 IN s_matgrp OR
lv_matg_code2 IN s_matgrp OR
lv_matg_code3 IN s_matgrp ).
MOVE: zzkioskact-reqdt TO lt_summary-reqdt,
lt_zzsvendor-appno TO lt_summary-appno,
lt_zzsvendor-vendor TO lt_summary-vendor,
lt_zzsvendor-ismbe TO lt_summary-ismbe,
lt_zzsvendor-iswbe TO lt_summary-iswbe,
lt_zzsvendor-isdbe TO lt_summary-isdbe,
lv_pcat1 TO lt_summary-pcat1,
lv_pcat2 TO lt_summary-pcat2,
lv_pcat3 TO lt_summary-pcat3.
CLEAR: lv_name1,
lv_adrnr,
lv_street,
lv_str_suppl3,
lv_city1,
lv_city2,
lv_region,
lv_post_code1,
lv_country,
lv_tel_number,
lv_fax_number,
lv_email.
SELECT name1 adrnr
INTO (lv_name1, lv_adrnr)
FROM lfa1
WHERE lifnr = lt_zzsvendor-vendor.
ENDSELECT.
IF lv_name1 IS NOT INITIAL.
MOVE lv_name1 TO lt_summary-vendorname.
ELSE.
SELECT name1
INTO lv_name1
FROM zzsvendor
WHERE appno = lt_zzsvendor-appno.
MOVE lv_name1 TO lt_summary-vendorname.
ENDSELECT.
ENDIF.
IF lv_adrnr IS NOT INITIAL.
SELECT smtp_addr
INTO lv_email
FROM adr6
WHERE addrnumber = lv_adrnr AND
flgdefault = 'X'.
MOVE lv_email TO lt_summary-smtp_addr.
ENDSELECT.
SELECT street str_suppl3 city1 city2 region post_code1 country
tel_number fax_number
INTO (lv_street,lv_str_suppl3, lv_city1, lv_city2,
lv_region, lv_post_code1, lv_country, lv_tel_number,
lv_fax_number)
FROM adrc
WHERE addrnumber = lv_adrnr.
MOVE lv_street TO lt_summary-street.
MOVE lv_str_suppl3 TO lt_summary-str_suppl3.
MOVE lv_city1 TO lt_summary-city1.
MOVE lv_city2 TO lt_summary-city2.
MOVE lv_region TO lt_summary-region.
MOVE lv_post_code1 TO lt_summary-post_code1.
MOVE lv_country TO lt_summary-country.
MOVE lv_tel_number TO lt_summary-tel_number.
MOVE lv_fax_number TO lt_summary-fax_number.
ENDSELECT.
ELSE. "No Vendor Number for this Application
SELECT cemail
INTO lv_email
FROM zzsvendor
WHERE appno = lt_zzsvendor-appno.
MOVE lv_email TO lt_summary-smtp_addr.
ENDSELECT.
ENDIF.
SELECT stras str_suppl3 ort01 non_us_regio regio pstlz
land1 telf1 telfx
INTO (lv_street,lv_str_suppl3, lv_city1, lv_city2,
lv_region, lv_post_code1, lv_country, lv_tel_number,
lv_fax_number)
FROM zzaddress
WHERE appno = lt_zzsvendor-appno AND
adrnr = '1'.
MOVE lv_street TO lt_summary-street.
MOVE lv_str_suppl3 TO lt_summary-str_suppl3.
MOVE lv_city1 TO lt_summary-city1.
MOVE lv_city2 TO lt_summary-city2.
MOVE lv_region TO lt_summary-region.
MOVE lv_post_code1 TO lt_summary-post_code1.
MOVE lv_country TO lt_summary-country.
MOVE lv_tel_number TO lt_summary-tel_number.
MOVE lv_fax_number TO lt_summary-fax_number.
ENDSELECT.
*Begin of changes by wb328936
MOVE lv_count TO lt_summary-po.
MOVE lv_total_amt TO lt_summary-povalue.
*End of changes by wb328936
APPEND lt_summary.
CLEAR lt_summary.
ENDIF.
ENDIF.
ENDLOOP.Hi Nagendra,
The variable lv_amt which you are importing from the FM Convert_To_Local_Currency is of type
Ekpo-Netwr and this field is of length 13(2) i.e 13 digits with 2 decimal places and for the value you pass to this Fm its returning a value into lv_amt which is of more length than 13(2).
So declare lv_amt as type P decimals 2 and then run your program.
My suggestion is that you increase the length of lv_amt by declaring it and not by giving it as type of Ekpo-Netwr and if you want it to be as Type of Ekpo-Netwr then pass a suitable value to FM so that it returns a value within the range of 13(2).
Hope this will help you.
Reward if useful.
With regards,
Syed -
CONVERT_TO_LOCAL_CURRENCY not working
Hi all,
I am trying to use the FM CONVERT_TO_LOCAL_CURRENCY to convert from one currency to other. The values for the currencies are maintained in the TCURR and TCURF tables also. However the Local amount field of the FM returns me a value *8392 and the transformation gives a dump.
Also when i execute the FM in SE37 it just returns me the exchange rate type of EURX and no other value.
Same is the issue with the FM CONVERT_TO FOREIGNCURRENCY.
Can some one please help urgently.
ThanksHi,
Which input parameters are you specifying?
Client 100 (or relevant client no)
Date 30.09.2011 (make sure this date exists in TCURR table) *
Foreign amount 1000 (some amount specified)
Foreign currency USD (make sure this "From currency" exists in TCURR table) *
Local currency TRL (make sure this "To currency" exists in TCURR table) *
Rate - space
Type of rate M (make sure this "type of rate" exists in TCURR table) *
*Should reside on the same TCURR row
Regards,
Dilek -
CONVERT_TO_LOCAL_CURRENCY not return correct amount
Hi expert,
I'm trying to convert 1000 USD to SGD using FM 'CONVERT_TO_LOCAL_CURRENCY'. As we know 1000 USD = 1736 SGD, but this FM return 17,36 SGD.
Kindly help me on this.
Below is the test code.
REPORT y_mr_exchange_rate.
DATA:
v_local_amount TYPE wertv8.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
date = sy-datum
foreign_amount = 1000
foreign_currency = 'USD'
local_currency = 'SGD'
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
* EXCHANGE_RATE =
* FOREIGN_FACTOR =
local_amount = v_local_amount
* LOCAL_FACTOR =
* EXCHANGE_RATEX =
* FIXED_RATE =
* DERIVED_RATE_TYPE =
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6
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 :
'CONVERT_TO_LOCAL_CURRENCY : ', v_local_amount CURRENCY 'SGD'.
RESULT :
CONVERT_TO_LOCAL_CURRENCY : 17,36hi,
try to add another couple of zeroes ...might be because of the last two digits being taken as decimal or being divided by 100...
regards,
syed -
CONVERT_TO_LOCAL_CURRENCY issue
Greeting Gurus,
Anybody have and idea why a call to function module CONVERT_TO_LOCAL_CURRENCY, while loading transaction data from R/3, is failing with a message "NO FACTORS FOUND"? I have successfully Transferred Exchange rates in RSA1 -> Source Systems from our R/3 system. I click the "Transfer Exchange rates again" radio button and execute. I see it replaces all records in my TCURR table successfully.
After debugging code for the past hour, I've determined its failing while processing records from TCURF. I also noted that TCURN is empty in R/3 but not in our BI 7.0 nw04s system.
Why isn't Transfer Exchange rates taking care of these tables in BI?
Also, any suggestions on how to get past this issue?
Regards,
AlexHi Alex,
You will need to also transfer the global settings (rigth click on Source system in RSA1). This will maintain the factors that are missing.
Hope this helps... -
FM for convert to local currency other than CONVERT_TO_LOCAL_CURRENCY
Does anyone know any other FM which converts into local currency???
But it should be other than CONVERT_TO_LOCAL_CURRENCY..Hi Ajay,
Just you can check it out in SE37.
CONVERT_TO_LOCAL_CURRENCY_N
CONVERT_TO_LOCAL_CURRENCY_O.
CONVERT_TO_FOREIGN_CURRENCY
Chk this Link
convert to local currency
Reward Points if Useful
Regards
Gokul -
Reg : CONVERT_TO_LOCAL_CURRENCY Fun Module
Hi All,
I am passing the values date 31.01.2009
foreign currency GBP
local currency USD
Foreign amount 100
the remainig parametrs are default.
but I am not getting any result.
Please help mein this, I have searched the forumand tried withs everal combinations.
but no result came.
Any suggestions wil be helpful.
Regards
Abhilash.Hello,
First the exchange rates should be maintained in the table TCURR. Please check this.
Also check the below sample.
DATA : L_NETWR TYPE VBAP-NETWR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = '18'
FOREIGN_CURRENCY = 'EUR'
LOCAL_CURRENCY = 'USD'
TYPE_OF_RATE = 'M'
IMPORTING
LOCAL_AMOUNT = L_NETWR
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
WRITE: L_NETWR.
Cheers,
Vasanth -
FM: CONVERT_TO_LOCAL_CURRENCY
Hi
Kinldy the me how to use the FM:CONVERT_TO_LOCAL_CURRENCY. I am not able to populate the values.
Foreign curency i used as USD and Local Currency as GPP.
Thanks and Regards
Yamini.AHi yamini,
check this it may help you......
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = 001
DATE = sy-datum
FOREIGN_CURRENCY = wa1-WAERS " here you need to declare your foreign currency i.e USD
LOCAL_CURRENCY = TCURR-FCURR
FOREIGN_AMOUNT = wa1-DMBTR " here you need to declare your amount field.
* RATE = tcurr-ukurs
TYPE_OF_RATE = 'M' " check this also the average rate
* READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE = tcurr-UKURS
* FOREIGN_FACTOR =
LOCAL_AMOUNT = wa1-TOTAL " this is the field where the converted amt has to be displayed.
* LOCAL_FACTOR =
* EXCHANGE_RATEX =
* FIXED_RATE =
* DERIVED_RATE_TYPE =
* EXCEPTIONS
* NO_RATE_FOUND = 1
* OVERFLOW = 2
* NO_FACTORS_FOUND = 3
* NO_SPREAD_FOUND = 4
* DERIVED_2_TIMES = 5
* OTHERS = 6
IF SY-SUBRC <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Translate foreign currency amount to local currency
An amount in local currency is calculated from a specified foreign currency amount. For this, you may either specify the translation rate manually (Parameter RATE) or have the system determine it from table TCURR on the basis of the rate type, date and currency key. Because the ratios for the units of the currencies involved in the translation are significant for this translation, table TCURF is always read by the program, and there must be a valid entry there for the data specified. IF exchange rate fixing is defined for the exchange rate type TYPE_OF_RATE or an alternative exchange rate is defined for the currency pair, this information is transferred to the calling program.
When table TCURR is read, the foreign currency key is always taken as the first part of the key and the local currency as the second part.
hope this helps you.
regards,
venu. -
Issue with CONVERT_TO_LOCAL_CURRENCY
I am using FM 'CONVERT_TO_LOCAL_CURRENCY' like below.
DATA: lv_fcurr TYPE tcurr-fcurr,
lc_lcurr(3) TYPE c VALUE 'CHF',
lc_type_rate(1) TYPE c VALUE 'M',
lc_read_tcurr(1) TYPE c VALUE 'X'.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
client = sy-mandt
date = sy-datum
foreign_amount = wa_ce11000-vv050
foreign_currency = lv_fcurr
local_currency = lc_lcurr
rate = 0
type_of_rate = lc_type_rate
read_tcurr = lc_read_tcurr
IMPORTING
local_amount = lv_conv_vv050.
IF sy-subrc = 0.
wa_ce11000-vv050 = lv_conv_vv050.
ENDIF.
and getting following wrror msg frm the FM while run my transaction.
"Enter rate /CHF rate type M for 00.00.0000in the system settings"
Please note if I give any hardcoded currency like 'EUR' instead of lv_fcurr, then this error is nt coming.
Can any one tell me what could be the problem??hello,
Use the FM in this way
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = p_sy_datum
foreign_amount = p_y_v_kbetr
foreign_currency = p_y_v_waers1
local_currency = p_y_v_waers
rate = 0
type_of_rate = 'M'
IMPORTING
local_amount = p_y_v_amt
EXCEPTIONS
OTHERS = 6.
or You can check in Tcode EWCT is the transcation to convert the currency
This Tcode uses the same FM. You can debug this Tcode also. -
I have the folling code and my local-amount returned is always incorrect if my exchange rate is this way 1.96-. It keeps multiplying by 1.96 when it needs to divide. what am I doing wrong??
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = COMM_STRUCTURE-CALDAY
FOREIGN_AMOUNT = COMM_STRUCTURE-NET_VALUE
FOREIGN_CURRENCY = COMM_STRUCTURE-DOC_CURRCY
LOCAL_CURRENCY = COMM_STRUCTURE-loc_currcy
LOCAL_RATE = COMM_STRUCTURE-EXCHG_RATE
RATE = COMM_STRUCTURE-EXCHG_RATE
LOCAL_TYPE_OF_RATE = US_RATE_TYPE
TYPE_OF_RATE = US_RATE_TYPE
IMPORTING
exchange_rate = t_er
foreign_factor = t_ff
local_factor = t_lf
LOCAL_AMOUNT = p_VALUE
EXCEPTIONS
no_rate_found = 1
no_factors_found = 2
no_spread_found = 3
derived_2_times = 4
overflow = 5
zero_rate = 6
OTHERS = 7.
RESULT = p_value.
else.
RESULT = COMM_STRUCTURE-NET_VALUE.
ENDIF.Hi
Just as I said in your previous post u should check how u transfer the value of the rate.
See this examples:
a):
PARAMETERS: P_AMOUNT LIKE BSEG-WRBTR,
P_KURSF LIKE BKPF-KURSF.
DATA: LOCAL_AMOUNT TYPE WRBTR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
DATE = SY-DATUM
FOREIGN_AMOUNT = P_AMOUNT
FOREIGN_CURRENCY = 'USD'
LOCAL_CURRENCY = 'EUR'
RATE = P_KURSF
IMPORTING
LOCAL_AMOUNT = LOCAL_AMOUNT
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6
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: P_AMOUNT CURRENCY 'USD', LOCAL_AMOUNT CURRENCY 'EUR'.
Here if you insert 1,96 in the selection-screen the value of the rate will be 1.96 - and the local value will be obteined by dividing the foreingn one.
PARAMETERS: P_AMOUNT LIKE BSEG-WRBTR,
P_RATE LIKE VBAP-NETWR.
DATA: LOCAL_AMOUNT TYPE WRBTR,
P_KURSF LIKE BKPF-KURSF.
MOVE P_RATE TO P_KURSF.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
DATE = SY-DATUM
FOREIGN_AMOUNT = P_AMOUNT
FOREIGN_CURRENCY = 'USD'
LOCAL_CURRENCY = 'EUR'
RATE = P_KURSF
IMPORTING
LOCAL_AMOUNT = LOCAL_AMOUNT
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6
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: P_AMOUNT CURRENCY 'USD', LOCAL_AMOUNT CURRENCY 'EUR'.
Here if it inserts 1,96-, when the value is transfered to the variable for the rate becomes 0.00196- so the local value is obteined by multiplying the foreingn one.
So in this last case:
PARAMETERS: P_AMOUNT LIKE BSEG-WRBTR,
P_KF_1 LIKE VBAP-NETWR.
DATA: LOCAL_AMOUNT TYPE WRBTR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
DATE = SY-DATUM
FOREIGN_AMOUNT = P_AMOUNT
FOREIGN_CURRENCY = 'USD'
LOCAL_CURRENCY = 'EUR'
RATE = P_KF_1
IMPORTING
LOCAL_AMOUNT = LOCAL_AMOUNT
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6
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: P_AMOUNT CURRENCY 'USD', LOCAL_AMOUNT CURRENCY 'EUR'.
It has the same result of the previous case because if it insert 1,96- it'll become 0,00196-.
It's very important the type of the rate is like BKPF-KURSF.
Max -
CONVERT_TO_LOCAL_CURRENCY currency conversion errors in Delta mode
Hello,
I have been working with SAP via customer messages for a month now with no resolution. As many of you have experienced, the SAP Level 1 support is pretty useless so I would like to check here to see if I can get some help.
I found a thread where another user has had the exact same problem as I have.
Problem: Exchange rate in Update rules with DELTA mode
However, there was no answer given to him. So, if anyone can help, I appreciate it. Here's the problem:
When a record comes through 2LIS_13_VDITM (for example), it had a document currency of EUR, a local currency of PLN and a statistical currency of USD. The first time the record comes through, it comes through just fine. The exchange rate from EUR to PLN is 3.533. The statistical currency value is calculated by taking the document currency value and multiplying it by the exchange rate from EUR to PLN to get the local currency. Then, this local currency is converted to USD by multiplying itself by the PLN to USD exchange rate of 1.519.
These are the exchange rates that are coming through as key figures on the transaction data. The problem is when a delta occurs. The data goes into the ODS and then once the update rules to the cube get it, the signs are backwards on the exchange rates. This makes sense so that the exchange rate key figures will cancel themselves out, but the SAP code says to calculate the local currency, it must first take the document currency and divide by the exchange rate. It should still be multiplying because the exchange rate from EUR to PLN is still 3.533. The negative on the key figure that is being zeroed out tells the code to divide though.
You cannot simply set the reversal indicator because the values that do come through ok would then be erraneous as the previous poster who had the same issue encountered. This is really causing some bad data for us. This is SAP delivered code. Any help would be appreciated.
Thanks,
Brenthi,
chk out various application currency conversion links
Need Urgent Help on Currency Conversion Routine
Currency conversion using transformation rule
http://help.sap.com/saphelp_nw04/helpdata/en/bc/058f4073b2f30ee10000000a155106/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/16/088f4073b2f30ee10000000a155106/frameset.htm
Ramesh -
Can you help me interpret the following lines in UPDATE rule?
Hi,
Can you help me interpret the following lines in UPDATE rule?
1. What is the role of role of u201CCHANGING RESULT.u201D and u201CCHANGING lc_local_value.u201D?
2. What is the role of the CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY', in particular the Exporting and Importing parts?
3. Can I say that u201CCOMM_STRUCTURE-ORDER_VALu201D in the subroutine is passed to u201Clc_document_valueu201D in the u201CFORM loc_curr_convertu201D; and further passed to u201Cforeign_amountu201D in the u201CCALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'u201D?
4. Finally, what becomes of my original u201CActual Goods receipt quantityu201D( 0GR_QTY ) which I am writing the routine for? I donu2019t see any where in the code that it is being referred to? Do any of these codes affect the value of 0GR_QTY?
5. Also, if there are 3 different subroutines in the INCLUDE and I am making the change described in #4 above, how do I know which of the 3 subroutines to call?
===============================
===============================
So I am reviewing a transfer routine in for u201CActual Goods receipt quantityu201D and routine an INCLUDE statement: INCLUDE RS_BCT_MM_UPDATE_RULES.
The update rule also includes the following properties to run the following subroutine in the Include:
IF u2026..
perFORM LOC_CURR_CONVERT
USING COMM_STRUCTURE-ORDER_VAL
COMM_STRUCTURE-DOC_DATE
COMM_STRUCTURE-ORDER_CURR
COMM_STRUCTURE-LOC_CURRCY
COMM_STRUCTURE-EXCHG_RATE
CHANGING RESULT.
I verified in the INCLUDE (RS_BCT_MM_UPDATE_RULES) and the subroutine is as follows:
FORM loc_curr_convert
USING lc_document_value
lc_date
lc_document_currency
value(lc_local_currency)
lc_rate
CHANGING lc_local_value.
conversion of lc_rate from floating-point to decimal. Necessary for *
call of CONVERT_TO_LOCAL_CURRENCY.
data lc_rate_dec type p decimals 5.
lc_rate_dec = lc_rate.
IF lc_document_currency = lc_local_currency
no conversion necessary -> Main case 1
AND NOT ( lc_document_currency IS INITIAL
OR lc_local_currency IS INITIAL ) .
lc_local_value = lc_document_value.
ELSEIF NOT ( lc_document_currency IS INITIAL
OR lc_local_currency IS INITIAL OR lc_date IS INITIAL ) .
conversion necessary with lc_date -> Normally not possible
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = lc_date
foreign_amount = lc_document_value
foreign_currency = lc_document_currency
local_currency = lc_local_currency
rate = lc_rate_dec
IMPORTING
EXCHANGE_RATE =
local_amount = lc_local_value
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5.
IF sy-subrc NE 0.
message a802 with lc_date lc_document_currency lc_local_currency
sy-subrc.
ENDIF.
ELSE.
if conversion not possible -> assign target values
lc_local_value = lc_document_value.
lc_local_currency = lc_document_currency.
ENDIF.
ENDFORM.HI,
Thanks so much the explanations.
I just verified again on our dev system and the update rule for 0GR_QTY (Actual goods receipt quantity) include the following:
perFORM QUANTITY_CONVERT
USING COMM_STRUCTURE-CPQUAOU
COMM_STRUCTURE-po_UNIT
COMM_STRUCTURE-base_uom
COMM_STRUCTURE-numerator
COMM_STRUCTURE-denomintr
CHANGING RESULT
Now, in the include, I also found:
FORM QUANTITY_CONVERT
USING QC_SOURCE_VALUE
QC_SOURCE_UNIT
VALUE(QC_TARGET_UNIT)
QC_UMREZ
QC_UMREN
CHANGING QC_TARGET_VALUE.
i. Does it mean it actually does quantity conversion?
ii. If you have access to the INCLUDE I will appreciate some hints on what the subroutine QUANTITY_CONVERT is doing. It does not appear do to be saying anything about quantity conversion; but it is supposed to be doing something with the parameters being passed from the update routine.
iii. In your response to #5, after all the computation in the INCLUDE, what comes back to the Update rule i.e. what comes back to become the value of 0GR_QTY?
Is it the u201CRESULT.u201D in the update rule or u201CQC_TARGET_VALUE.u201D in the subroutine in the INCLUDE.
iv. So, am to create an Update rule for 0PSTNG_DATE and the source is BUDAT; and I need to write a routine using the include INCLUDE RS_BCT_MM_UPDATE_RULES.
I looked through the INCLUDE and identified all the subroutines in this INCLUDE as follows:
QUANTITY_CONVERT
LOC_CURR_CONVERT
GET_WEEK
WEEK_DAY
QUARTER_DAY
--Does it mean that to use this subroutine, I can only use the USING parameters of one of these listed subroutines?
--Also, does it mean that because 0PSTNG_DATE is a date, I can only use one of
GET_WEEK
WEEK_DAY
QUARTER_DAY
--Or, are there other includes to be used for 0PSTNG_DATE
Thanks -
WS14500015 is not working for Multilevel approval
We are trying to Implement the Workflow Template Ws14500015. We have implemented the BADI BBP_WFL_APPROVE_BADI. The workflow works perfectly for 1st level approval. We have checked that the ApproverList Container element gets pouplated with 3 levels of approval when 1 st level approver has not approved it. But as soon as the first level approver approves it this container element is updated with one entry. Please review the code I am attaching. Any help will be highly appreciated.
METHOD if_ex_bbp_wfl_approv_badi~get_remaing_approvers .
Interface parameters:
OBJECT_ID TYPE CRMT_OBJECT_ID "Import
OBJECT_TYPE TYPE CRMT_SUBOBJECT_CATEGORY "Import
GUID TYPE BBP_GUID_32 "Import
ACTUAL_APPROVAL_INDEX TYPE SWH_NUMC10 "Import
APPROVAL_HISTORY_TABLE TYPE BBP_WFL_APPROVAL_HISTORY_BADI "Import
ITEM_APPROVAL_HISTORY_TABLE TYPE BBPT_WFL_ITEM_APPROVAL_BADI "Import
APPROVAL_TABLE TYPE BBPT_WFL_APPROVAL_TABLE_BADI "Export
ITEM_APPROVAL_TABLE TYPE BBPT_WFL_ITEM_APPROVAL_BADI "Export
NO_FURTHER_APPROVAL_NEEDED TYPE BOOLEAN "Export
ITEM_APPROVAL_OBJ TYPE BBPT_WFL_ITEM_APPROVAL_OBJ "Changing
This a default implementation that gives idea about of how line item
approval should work as well to find the number of approval required
and to find the approvers.
Global data---------------------------------------------------------*
TYPES---------------------------------------------------------------*
TYPES : ty_item_info TYPE STANDARD TABLE OF /fir/rmm0bgst001.
"to have the necessary values of custom table .
DATA----------------------------------------------------------------*
DATA : it_item_info TYPE ty_item_info,"to store the approval values.
wa_item_info TYPE /fir/rmm0bgst001. " work area for item_info.
DATA : v_value_per_cctr TYPE bbp_value, " contain value per account
" type in line item of SC
v_value_per TYPE bbp_value. " value for v_value_per_cctr
" in USD
DATA : v_apprv_value TYPE bbp_value. " amount of first level.
DATA: v_call_value1 TYPE bbp_wfl_app_property,"have cost_ctr,
"asset_no or order_no value.
v_co_code TYPE bbp_wfl_app_property," have company code
v_plant_value TYPE bbp_wfl_app_property," have plant value
v_account_type TYPE bbp_wfl_app_criterion ," Account type
" ie COST_CTR, ASSET_NO or ORDER_NO.
v_comp_code TYPE bbp_wfl_app_criterion ,"COMP_CODE
v_plant TYPE bbp_wfl_app_criterion ," PLANT
v_acc_desc TYPE bbp_step_description ." approval desc.
WORKAREA------------------------------------------------------------*
DATA: wa_header TYPE bbp_pds_sc_header_d, " header of line
" item
tables and work area.
it_item TYPE TABLE OF bbp_pds_sc_item_d,
" line item details
wa_item TYPE bbp_pds_sc_item_d,
" have one line item detail.
accounting structures
it_account TYPE TABLE OF bbp_pds_acc,
" account details
wa_account TYPE bbp_pds_acc .
" one account details.
DATA: v_req TYPE bbp_wfl_app_criterion. " for creator.
CONSTANTS-----------------------------------------------------------*
Business objects
CONSTANTS:
c_po TYPE crmt_subobject_category_db VALUE 'BUS2201',
c_shop TYPE crmt_subobject_category_db VALUE 'BUS2121',
c_contract TYPE crmt_subobject_category_db VALUE 'BUS2000113'.
Approval Criteria and properties used
CONSTANTS:
c_cost_centre TYPE bbp_wfl_app_criterion VALUE 'COST_CTR',
c_order_no TYPE bbp_wfl_app_criterion VALUE 'ORDER_NO',
c_asset_no TYPE bbp_wfl_app_criterion VALUE 'ASSET_NO',
c_comp_code TYPE bbp_wfl_app_criterion VALUE 'COMP_CODE',
c_plant TYPE bbp_wfl_app_criterion VALUE 'PLANT',
c_cc_desc TYPE bbp_step_description VALUE
'Cost center approval',
c_io_desc TYPE bbp_step_description VALUE
'Order type approval',
c_as_desc TYPE bbp_step_description VALUE
'Asset Num approval',
c_usd TYPE char3 VALUE 'USD',
c_m TYPE char1 VALUE 'M',
c_x TYPE char1 VALUE 'X',
c_apprv_times TYPE char1 VALUE 3,
c_1 TYPE char2 VALUE '1',
c_as TYPE BBP_ACC_CAT VALUE 'AS',
c_or TYPE BBP_ACC_CAT VALUE 'OR',
c_cc TYPE BBP_ACC_CAT VALUE 'CC',
c_us TYPE char2 VALUE 'US'.
Case when the object type bus212...---------------------------------*
CASE object_type.
WHEN c_shop.
----------- shopping cart --------------------------------------- *
IF NOT approval_table[] IS INITIAL.
approval_history_table[] = approval_table[].
item_approval_history_table[] = item_approval_table[].
REFRESH : approval_table, item_approval_table,
item_approval_obj .
ENDIF.
REFRESH : it_item,it_account.
Get the details of the shopping cart
CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
EXPORTING
i_object_id = object_id
IMPORTING
e_header = wa_header
TABLES
e_item = it_item
e_account = it_account.
Proceed if it_item is not initial.
IF NOT it_item IS INITIAL AND NOT it_account IS INITIAL.
*read the lt_item for plant
READ TABLE it_item INTO wa_item INDEX 1.
CHANGE FOR REQEUSTOR.
CONCATENATE c_us wa_item-created_by INTO v_req.
now read the table with wa_item-be_plant.
SELECT *
FROM /fir/rmm0bgst001
INTO TABLE it_item_info
WHERE zplant = wa_item-be_plant.
SORT it_item BY guid .
SORT it_account BY p_guid .
IF actual_approval_index LE c_apprv_times AND
actual_approval_index GE c_1.
looping at it_item is done to fetch the approver for every
line item
CLEAR: wa_item, wa_account.
LOOP AT it_item INTO wa_item WHERE del_ind IS INITIAL.
LOOP AT it_account INTO wa_account
WHERE p_guid = wa_item-guid.
to calculate the amount before calling the funciton module for
approval table.value respective to account type
v_value_per_cctr =
wa_account-distr_perc * wa_item-value / 100.
read the table respective to account type and for level 1 approval
such that if the value is less than zvalue then no approval required.
CLEAR: wa_item_info.
CASE wa_account-acc_cat .
WHEN c_or.
READ TABLE it_item_info INTO wa_item_info
WITH KEY zlevel = c_1 " 1
zorder_no = wa_account-order_no
zplant = wa_item-be_plant.
WHEN c_as.
READ TABLE it_item_info INTO wa_item_info
WITH KEY zlevel = c_1 " 1
zasset_no = wa_account-asset_no
zplant = wa_item-be_plant.
WHEN c_cc.
READ TABLE it_item_info INTO wa_item_info
WITH KEY zlevel = c_1 " 1
zcost_ctr = wa_account-cost_ctr
zplant = wa_item-be_plant.
ENDCASE.
IF sy-subrc = 0.
v_apprv_value = wa_item_info-zvalue.
ENDIF.
now convert the amount to local currency ie usd
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
date = sy-datum
foreign_amount = v_value_per_cctr
foreign_currency = wa_item-currency
local_currency = c_usd
type_of_rate = c_m
read_tcurr = c_x
IMPORTING
local_amount = v_value_per
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6
IF v_value_per GE v_apprv_value AND sy-subrc = 0.
To Find out Account id of what type ie cost center/IO/Asset.
IF wa_account-acc_cat eq c_cc.
v_call_value1 = wa_account-cost_ctr.
v_account_type = c_cost_centre.
v_acc_desc = c_cc_desc. "'Cost center approval'.
ELSEIF wa_account-acc_cat eq c_or.
v_call_value1 = wa_account-order_no.
v_account_type = c_order_no.
v_acc_desc = c_io_desc. "'Internal Order approval'.
ELSE.
IF NOT wa_account-asset_no IS INITIAL.
v_call_value1 = wa_account-asset_no.
v_account_type = c_asset_no..
v_acc_desc = c_as_desc. "'Asset Number approval'.
ENDIF.
ENDIF.
Defining the PLANT and plant value.
v_plant = c_plant.
v_plant_value = wa_item-be_plant.
defining the COMPNAY CODE and company value.
v_comp_code = c_comp_code.
v_co_code = wa_item-be_co_code.
Calling the Custom function to find the approvers.
CALL FUNCTION '/FIR/RP2P0BGS_ITEM_APPRV_GET'
EXPORTING
sc_guid = wa_header-guid
item_guid = wa_item-guid
approval_description = v_acc_desc
hide_items_not_responsible = c_x "'X'
each cost center approver should see only items he is responsible
criterion1 = v_account_type
criterion2 = v_comp_code
criterion3 = v_plant
value1 = v_call_value1
value2 = v_co_code
value3 = v_plant_value
approval_index = actual_approval_index
TABLES
it_item_info = it_item_info
CHANGING
approval_table = approval_table
item_approval_table = item_approval_table
item_approval_obj = item_approval_obj.
ENDIF." end if if value per cost center is more than
" level one price.
CLEAR wa_account.
ENDLOOP. " end of loop of account.
CLEAR: wa_account,wa_item, wa_item_info.
ENDLOOP. " end of loop at item
CHANGE FOR REQUESTOR.----
DELETE approval_table WHERE approval_agent = v_req.
IF approval_table IS INITIAL.
no_further_approval_needed = c_x. " 'X'.
ENDIF.
ELSE. " end of if actual_approval_index le 3.
this BADI-implementation defines 3 steps
no_further_approval_needed = c_x. "'X'.
ENDIF.
ENDIF. " end of if the it_item is not initial.
ENDCASE. "end of case if bus type is 2121
ENDMETHOD.
Function Module
FUNCTION /fir/rp2p0bgs_item_apprv_get .
""Local Interface:
*" IMPORTING
*" REFERENCE(SC_GUID) TYPE BBP_GUID OPTIONAL
*" REFERENCE(ITEM_GUID) TYPE BBP_GUID OPTIONAL
*" REFERENCE(APPROVAL_DESCRIPTION) TYPE BBP_STEP_DESCRIPTION
*" OPTIONAL
*" REFERENCE(HIDE_ITEMS_NOT_RESPONSIBLE) TYPE BOOLEAN OPTIONAL
*" REFERENCE(CRITERION1) TYPE BBP_WFL_APP_CRITERION OPTIONAL
*" REFERENCE(CRITERION2) TYPE BBP_WFL_APP_CRITERION DEFAULT ''
*" REFERENCE(CRITERION3) TYPE BBP_WFL_APP_CRITERION DEFAULT ''
*" REFERENCE(VALUE1) TYPE BBP_WFL_APP_PROPERTY DEFAULT ''
*" REFERENCE(VALUE2) TYPE BBP_WFL_APP_PROPERTY DEFAULT ''
*" REFERENCE(VALUE3) TYPE BBP_WFL_APP_PROPERTY DEFAULT ''
*" REFERENCE(APPROVAL_INDEX) TYPE SWH_NUMC10 OPTIONAL
*" TABLES
*" IT_ITEM_INFO STRUCTURE /FIR/RMM0BGST001
*" CHANGING
*" REFERENCE(APPROVAL_TABLE) TYPE BBPT_WFL_APPROVAL_TABLE_BADI
*" REFERENCE(ITEM_APPROVAL_TABLE) TYPE BBPT_WFL_ITEM_APPROVAL_BADI
*" REFERENCE(ITEM_APPROVAL_OBJ) TYPE BBPT_WFL_ITEM_APPROVAL_OBJ
*" OPTIONAL
Local data-----------------------------------------------------------*
TYPES: ty_option TYPE STANDARD TABLE OF rfc_db_opt,
ty_fields TYPE STANDARD TABLE OF rfc_db_fld,
ty_data TYPE STANDARD TABLE OF tab512.
DATA:
wa_approval_table TYPE bbp_wfl_approval_table_badi,
wa_item_approval_table TYPE bbps_wfl_item_approval,
wa_approval_def TYPE /fir/rmm0bgst001.
DATA:
v_app_obj_guid TYPE bbp_guid_32,
v_is_new_approval_object TYPE boolean.
DATA : it_update_tab TYPE STANDARD TABLE OF /fir/rmm0bgst001,
it_approval_def TYPE STANDARD TABLE OF /fir/rmm0bgst001,
wa_update_tab TYPE /fir/rmm0bgst001.
DATA : it_actor_tab TYPE STANDARD TABLE OF swhactor,
wa_actor_tab TYPE swhactor,
it_ac_container TYPE STANDARD TABLE OF swcont,
wa_ac_container TYPE swcont.
DATA : it_options TYPE ty_option,
it_fields TYPE ty_fields,
it_data TYPE ty_data.
DATA : wa_options TYPE rfc_db_opt,
wa_fields TYPE rfc_db_fld,
wa_data TYPE tab512.
DATA : v_apprv_io TYPE aufuser2,
v_apprv_cc TYPE verak.
DATA : v_cost_ctr TYPE bbp_wfl_app_property ,
v_order_no TYPE bbp_wfl_app_property ,
v_asset_no TYPE bbp_wfl_app_property ,
v_as_value TYPE bbp_wfl_app_property .
DATA : v_query_table TYPE dd02l-tabname.
DATA : v_apprv_count TYPE char1 VALUE '0'.
to find the number of lines in the table it_update_tab.
DATA : v_lines TYPE i.
DATA : v_app_ind TYPE swh_numc10 VALUE '0'.
DATA : v_destination TYPE char10,
v_system TYPE sysysid,
v_mandt TYPE symandt.
Constants-----------------------------------------------------------*
CONSTANTS:
c_clnt TYPE char4 VALUE 'CLNT',
c_agent_is_user TYPE otype VALUE 'US',
c_x TYPE char1 VALUE 'X',
c_cost_centre TYPE bbp_wfl_app_criterion VALUE 'COST_CTR',
c_order_no TYPE bbp_wfl_app_criterion VALUE 'ORDER_NO',
c_asset_no TYPE bbp_wfl_app_criterion VALUE 'ASSET_NO',
c_csks TYPE char4 VALUE 'CSKS',
c_anlz TYPE char4 VALUE 'ANLZ',
c_coas TYPE char4 VALUE 'COAS',
c_verak TYPE char5 VALUE 'VERAK',
c_user2 TYPE char5 VALUE 'USER2',
c_kostl TYPE char5 VALUE 'KOSTL',
c_aufnr TYPE char5 VALUE 'AUFNR',
c_bukrs TYPE char5 VALUE 'BUKRS',
c_anln1 TYPE char5 VALUE 'ANLN1',
c_c TYPE char1 VALUE 'C',
c_and TYPE char3 VALUE 'AND',
c_eq TYPE char1 VALUE '=',
c_org_object TYPE swc_elem VALUE 'ORG_OBJECT',
c_deli TYPE char1 VALUE '|',
c_l12 TYPE ddleng VALUE '000012',
c_off0 TYPE doffset VALUE '000000',
c_l10 TYPE ddleng VALUE '000010',
c_l20 TYPE ddleng VALUE '000020',
c_l04 TYPE ddleng VALUE '000004',
c_ind01 TYPE swc_index VALUE '000001',
c_el06 TYPE swc_length VALUE '006',
c_tab_name TYPE tabname VALUE '/fir/rmm0bgst001',
c_r10 TYPE sysysid VALUE 'R10',
c_r15 TYPE sysysid VALUE 'R15',
c_r20 TYPE sysysid VALUE 'R20',
c_r40 TYPE sysysid VALUE 'R40',
c_e10 TYPE sysysid VALUE 'E10',
c_e15 TYPE sysysid VALUE 'E15',
c_e20 TYPE sysysid VALUE 'E20',
c_e40 TYPE sysysid VALUE 'E40',
c_121 TYPE symandt VALUE '121',
c_300 TYPE symandt VALUE '300',
c_100 TYPE symandt VALUE '100',
c_120 TYPE symandt VALUE '120',
begin of change for generic entry 06-06-2007----
c_cc TYPE kostl VALUE 'CC',
c_as TYPE anln1 VALUE 'AS',
c_or TYPE aufnr VALUE 'OR'.
end of change for generic entry 06-06-2007----
-perpare the system and client for RFC----
CASE sy-sysid .
WHEN c_r10. "' R10'.
IF sy-mandt = c_120. " '120'.
CONCATENATE c_e10 c_clnt c_121 INTO v_destination.
ENDIF.
WHEN c_r15. " 'R15'.
IF sy-mandt = c_120. " '120'.
CONCATENATE c_e15 c_clnt c_300 INTO v_destination.
ENDIF.
WHEN c_r20. " 'R20'.
IF sy-mandt = c_300. " '300'.
CONCATENATE c_e20 c_clnt c_300 INTO v_destination.
ENDIF.
WHEN c_r40. " 'R40'.
IF sy-mandt = c_100. " '100'.
CONCATENATE c_e40 c_clnt c_100 INTO v_destination.
ENDIF.
ENDCASE.
Comment on logic ---------------------------------------------------*
First find the right approval object the item belongs to.
All items of an approval object are approved together in
this approval step, and therefore only one workitem is
created for this items.
CALL FUNCTION 'BBP_WFL_DIN_APP_OBJ_GET'
EXPORTING
sc_guid = sc_guid
criterion1 = criterion1
value1 = value1
IMPORTING
If 2 items of the same shopping cart have the same
values for the criterias, this function returns the
same (!!!) approval object guid
approval_obj_guid = v_app_obj_guid
TABLES
item_app_obj = item_approval_obj
Check what type of account is ie Order no/Internal order/ASSET.
if the account type is asset_no then responsible cost center is
found.
CLEAR: it_update_tab, wa_update_tab.
CASE criterion1 .
WHEN c_asset_no. " 'ASSET_NO'.
v_asset_no = value1.
CONCATENATE c_anln1 c_eq value1 " 'ANLN1' '=' value1
c_and c_bukrs c_eq value2 INTO wa_options-text
SEPARATED BY space.
APPEND wa_options TO it_options.
wa_fields-fieldname = c_anln1. " 'ANLN1'.
wa_fields-length = c_l12. " '000012'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
wa_fields-fieldname = c_kostl. " 'KOSTL'.
wa_fields-length = c_l10. " '000010'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
wa_fields-fieldname = c_bukrs. " 'BUKRS'.
wa_fields-length = c_l04. " '000004'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
CALL FUNCTION 'RFC_READ_TABLE' DESTINATION v_destination
EXPORTING
query_table = c_anlz " 'ANLZ'
delimiter = c_deli " '|'
TABLES
OPTIONS = it_options
fields = it_fields
data = it_data
EXCEPTIONS
table_not_available = 1
table_without_data = 2
option_not_valid = 3
field_not_valid = 4
not_authorized = 5
data_buffer_exceeded = 6
OTHERS = 7.
IF sy-subrc = 0.
as it_data table contains only one record
so no sorting required.
READ TABLE it_data INTO wa_data INDEX 1.
v_as_value = wa_data-wa+13(10).
ENDIF.
at the end of this if asset is passed its responsible
cost is obtained and is placed in value1 field.
CLEAR : wa_data , wa_options , wa_fields .
REFRESH: it_data , it_options , it_fields .
v_cost_ctr = v_as_value.
CONCATENATE c_kostl c_eq v_cost_ctr INTO wa_options-text
SEPARATED BY space.
APPEND wa_options TO it_options.
CLEAR: wa_fields.
wa_fields-fieldname = c_verak. " 'VERAK'.
wa_fields-length = c_l20. " '000020'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
CLEAR: wa_fields.
wa_fields-fieldname = c_kostl. " 'KOSTL'.
wa_fields-length = c_l10. " '000010'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
v_query_table = c_csks. " 'CSKS'.
set the initial value of v_asset_no by value1.
CLEAR: v_cost_ctr .
v_asset_no = value1.
WHEN c_cost_centre . " 'COST_CTR' or 'ASSET_NO'.
v_cost_ctr = value1.
CONCATENATE c_kostl c_eq v_cost_ctr INTO wa_options-text
SEPARATED BY space.
APPEND wa_options TO it_options.
CLEAR: wa_fields.
wa_fields-fieldname = c_verak. " 'VERAK'.
wa_fields-length = c_l20. " '000020'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
CLEAR: wa_fields.
wa_fields-fieldname = c_kostl. " 'KOSTL'.
wa_fields-length = c_l10. " '000010'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
v_query_table = c_csks. " 'CSKS'.
WHEN c_order_no. " 'ORDER_NO'.
v_order_no = value1.
CONCATENATE c_aufnr c_eq value1 INTO wa_options-text
SEPARATED BY space.
APPEND wa_options TO it_options.
CLEAR: wa_fields.
wa_fields-fieldname = c_user2. " 'USER2'.
wa_fields-length = c_l20. " '000020'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
CLEAR: wa_fields.
wa_fields-fieldname = c_aufnr. " 'AUFNR'.
wa_fields-length = c_l12. " '000012'.
wa_fields-offset = c_off0. " '000000'.
wa_fields-type = c_c. " 'C'.
APPEND wa_fields TO it_fields.
v_query_table = c_coas. " 'COAS'.
ENDCASE.
LOOP AT it_item_info INTO wa_update_tab
WHERE
zplant = value3 AND
zcost_ctr = v_cost_ctr AND
zorder_no = v_order_no AND
zasset_no = v_asset_no.
APPEND wa_update_tab TO it_update_tab .
ENDLOOP.
-begin of change for generic entry 06-06-2007----
it_update_tab may or may not contain the value as the per the data
maintainted. if initial then only generic value is maintained and the
the record need to be appended.
so the record which need to be appended shud be appended to
it_update_tab appropiatly with the amt of generic entry.
CLEAR : wa_update_tab.
CASE criterion1 .
WHEN c_asset_no.
READ TABLE it_item_info INTO wa_update_tab WITH KEY
zplant = value3
zasset_no = c_as."'AS'
IF sy-subrc = 0.
wa_update_tab-zasset_no = v_asset_no .
wa_update_tab-zlevel = 1.
APPEND wa_update_tab TO it_update_tab.
ENDIF.
WHEN c_cost_centre.
READ TABLE it_item_info INTO wa_update_tab WITH KEY
zplant = value3
zcost_ctr = c_cc."'CC'
IF sy-subrc = 0.
wa_update_tab-zcost_ctr = v_cost_ctr .
wa_update_tab-zlevel = 1.
APPEND wa_update_tab TO it_update_tab.
ENDIF.
WHEN c_order_no.
READ TABLE it_item_info INTO wa_update_tab WITH KEY
zplant = value3
zorder_no = c_or."'OR'
IF sy-subrc = 0.
wa_update_tab-zorder_no = v_order_no .
wa_update_tab-zlevel = 1.
APPEND wa_update_tab TO it_update_tab.
ENDIF.
ENDCASE.
end of change for generic entry 06-06-2007----
RFC to read table for finding the person responsible for the
cost center / order ie approver.
CALL FUNCTION 'RFC_READ_TABLE' DESTINATION v_destination
EXPORTING
query_table = v_query_table
delimiter = c_deli "'|'
TABLES
OPTIONS = it_options
fields = it_fields
data = it_data
EXCEPTIONS
table_not_available = 1
table_without_data = 2
option_not_valid = 3
field_not_valid = 4
not_authorized = 5
data_buffer_exceeded = 6
OTHERS = 7.
IF sy-subrc = 0.
CLEAR :wa_approval_def.
READ TABLE it_data INTO wa_data INDEX 1.
IF v_query_table = c_csks. " 'CSKS'.
v_apprv_cc = wa_data-wa+0(20).
wa_approval_def-zapprover = v_apprv_cc.
ELSE.
v_apprv_io = wa_data-wa+0(20).
wa_approval_def-zapprover = v_apprv_io.
ENDIF.
ENDIF.
find the number of record in the update table.
DESCRIBE TABLE it_update_tab LINES v_lines.
The updation of table runs only for the number of records
avaiable in the update table ie v_lines.
DO v_lines TIMES. " begin of do to approval index times.
CLEAR: it_approval_def.
v_apprv_count = v_apprv_count + 1.
wa_approval_def-zlevel = v_apprv_count .
if the count is more than one then next level of approver
is found using the rfc call swx_get_manager and stored as per.
IF v_apprv_count > 1.
v_apprv_count = v_apprv_count - 1.
READ TABLE it_update_tab INTO wa_update_tab
WITH KEY zlevel = v_apprv_count .
IF sy-subrc = 0 .
NOW FOR FINDING THE SECOND LEVEL OF APPROVER
1ST LEVEL OF APPROVER IS FOUND USING ABOVE READ.
THE FIRST LEVEL OF APPROVER IS USED TO FIND THE SECOND
LEVEL OF APPROVER USING THE SWX_GET_MANAGER.
PREPARE THE TABLES FOR SWX_GET_MANAGER
REFRESH : it_ac_container.
wa_ac_container-element = c_org_object. " 'ORG_OBJECT'.
wa_ac_container-tab_index = c_ind01. " '000001'.
wa_ac_container-elemlength = c_el06. " '006'.
wa_ac_container-type = c_c. " 'C'.
CONCATENATE c_agent_is_user wa_update_tab-zapprover
INTO wa_ac_container-value .
APPEND wa_ac_container TO it_ac_container.
CALL FUNCTION 'SWX_GET_MANAGER' DESTINATION v_destination
TABLES
actor_tab = it_actor_tab
ac_container = it_ac_container
EXCEPTIONS
nobody_found = 1
OTHERS = 2.
IF sy-subrc = 0.
READ TABLE it_actor_tab INTO wa_actor_tab WITH KEY
otype = c_agent_is_user.
wa_approval_def-zapprover = wa_actor_tab-objid.
ENDIF.
ENDIF.
v_apprv_count = v_apprv_count + 1.
ENDIF.
before updating populate the table it_approval_def
it_update_tab is read based on next v_apprv_count and
updates the approver and its value.
READ TABLE it_update_tab INTO wa_update_tab
WITH KEY zlevel = v_apprv_count .
IF sy-subrc = 0.
wa_approval_def-zplant = wa_update_tab-zplant.
wa_approval_def-zcost_ctr = wa_update_tab-zcost_ctr.
wa_approval_def-zorder_no = wa_update_tab-zorder_no.
wa_approval_def-zasset_no = wa_update_tab-zasset_no.
wa_approval_def-zvalue = wa_update_tab-zvalue.
APPEND wa_approval_def TO it_approval_def.
modify the table it_update_tab so that along with the custom
database table the table in use in this function module ie
it_update_tab also remain updated.
benefit is that if the modify to dtab fails. the process works fine.
MODIFY it_update_tab FROM wa_approval_def
TRANSPORTING zapprover
WHERE zlevel = wa_approval_def-zlevel AND
zvalue = wa_approval_def-zvalue.
now enqueue the table for modification.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = c_tab_name " '/fir/rmm0bgst001'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
now modify the table, for updation of approver.
IF sy-subrc = 0.
MODIFY /fir/rmm0bgst001 FROM wa_approval_def.
if sy-subrc goes 0 commit work is called.
also the it_update_tab need to be updated.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
ENDIF.
now dequeue the table after the updation.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = c_tab_name. " '/fir/rmm0bgst001'.
ENDIF.
once all done clear the work areas.
CLEAR : wa_approval_def-zlevel , wa_approval_def-zapprover.
ENDDO. " END OF DO STATEMENT.
SORT it_approval_def BY zlevel ASCENDING.
as per the logic for the different level of approval.
for second level of approval only records above 2 should be
present in the apprval table.
so for approval index = 2 delete the first record ie for zlevel = 1.
and for approval index = 3 delete first two records ie zlevel = 1 and
zlevel = 2. thus only one approval of zlevel 3 is left in the table
which is used to update the approval table.
IF approval_index = 2 .
DELETE it_approval_def INDEX 1.
ELSEIF approval_index = 3.
DELETE it_approval_def INDEX 1.
DELETE it_approval_def INDEX 1.
ELSEIF approval_index GT 3.
REFRESH : it_approval_def .
ENDIF.
for above 3 as approval index there shud be no enteries in the table.
so the table is refreshed and thus the approval table will not
contain anything.
approval_index is assigned to a varaiable
v_app_ind = approval_index.
v_app_ind is incremented for every next record so that approver is
assigned to next approval index.
beign of change 28th may 2007----
clear : v_app_ind .
v_app_ind = v_app_ind + 1.
LOOP AT it_approval_def INTO wa_approval_def.
wa_approval_table-approval_index = v_app_ind.
CONCATENATE c_agent_is_user wa_approval_def-zapprover
INTO wa_approval_table-approval_agent.
wa_approval_table-approval_description = approval_description.
wa_approval_table-approval_object_guid = v_app_obj_guid.
wa_approval_table-hide_items_not_responsible =
hide_items_not_responsible.
APPEND wa_approval_table TO approval_table.
v_app_ind = v_app_ind + 1 .
CLEAR: wa_approval_def.
ENDLOOP.
sort the approval table so that approvers come in sequence.
SORT approval_table BY approval_index.
ENDIF.
fill item table (which items belongs to which approval object)
wa_item_approval_table-approval_object_guid = v_app_obj_guid.
wa_item_approval_table-approval_item_guid = item_guid.
APPEND wa_item_approval_table TO item_approval_table.
CLEAR :wa_item_approval_table,wa_approval_table,it_update_tab.
ENDFUNCTION.
Thanks
Arghadip
[email protected]Hi,
You have to debug the entire system behaviour , the approval process using the second approver.
As first step , please check the security level of the second approver. Restart of workflow is based on the security level of the approver.
you can find the parameter for security level in the personalization tab of the user .
there is one function module which determines wether the workflow should be restarted (or) not.
i do not remember the exact name of the function module.
1)start transaction se37
2)enter bbpwflrestart*.
3) system will return a number of function modules , of them one function module determines wether to restart the workflow (or) not.
Please check what does the above function module return for the user and the shopping cart , there will be one parameter 'restart' which triggers the start -
How can i get currency values from flatfile to function module
Dear All,
I have to take currency values from flat file and i have to assign those flat file value to function module .
Eg: "Convert_to_local_currency". I need technical code how to calculate those amount in work area and how to assign those amount value function module.
I need sample program for currency conversion from flat file to function module. My requirement is based on flat file amount i have to calculate in work area and assign those work area to function module.
With Regards,
BaskaranHi Satish or Baskaran,
First conform in which format the flat file is present, as abhi mentioned if it is there in notepad
try to use F.M GUI_UPLOAD as shown below...
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Desktop\rpf1.TXT'
TABLES
DATA_TAB = ITAB.
Now loop at ITAB Into Work_area and press the respect currency fields which you want and in the same way
if the file is in EXCEL format use F.M ALSM_EXCEL_TO_INTERNAL_TABLE
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = P_FNAME
i_begin_col = 1
i_begin_row = 1
TABLES
intern = ITAB
LOOP AT ITAB INTO WA.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
foreign_currency = wa-waers
local_currency = wa-waers
IMPORTING
local_amount = tvals-gross.
ENDIF.
endloop.
And as mentioned loop the records into work area and process the currenct field which is present in the
ITAB according to its field name. And make sure within the loop you call your function module.
Regards
VEnk@
Edited by: Venkat Reddy on Dec 9, 2009 5:51 PM -
Hi All,
i have two checkbox options for the output,
1. create file
2.create detail report
If the Create file is checked, then i've to proceed with transfer of file and then show the selection screen data and the no of records transferred.
If the create Detailed Report is check, then proceed with the ALV display.
i.e here we should not transfer the file but display only the records and the top of page for the ALV should be displayed
If the Create file and Detailed report is both checked, the file transfer should occur and then we have to show the ALV output and the top-of-page for ALV only.
i.e here we should add the no of data transferred, Date and the physical path should be displayed in the top-of-page.
please tell me how to do.
REPORT ZPPI0036
$$----
$$ Standard routines and definitions
$$----
Include ZBSN0001. "Report Headers
Include ZBSN0003. "Common Routines
INCLUDE ZSDN0004. "Common Routines
$$----
$$ Tables-definitions
$$----
TABLES : ZVMATLMOVE,
T161,
T001W,
T024E,
T156,
EKKO,
LFA1,
TVARV,
MARA,
MARC,
EKPO,
T024,
Z_LFA1,
M_PRCTN.
$$----
$$ Internal tables definition
$$----
Begin of SIR 090216
*DATA I_MATLMOVE LIKE ZVMATLMOVE OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF I_MATLMOVE OCCURS 0,
MBLNR TYPE MSEG-MBLNR,
MJAHR TYPE MSEG-MBLNR,
BUDAT TYPE MKPF-BUDAT,
ZEILE TYPE MSEG-ZEILE,
BWART TYPE MSEG-BWART,
MATNR TYPE MSEG-MATNR,
WERKS TYPE MSEG-WERKS,
LGORT TYPE MSEG-LGORT,
LIFNR TYPE MSEG-LIFNR,
WAERS TYPE MSEG-WAERS,
MENGE TYPE MSEG-MENGE,
MEINS TYPE MSEG-MEINS,
EBELN TYPE MSEG-EBELN,
EBELP TYPE MSEG-EBELP,
PRCTR TYPE MSEG-PRCTR,
END OF I_MATLMOVE.
DATA : BEGIN OF I_OUTPUT OCCURS 0.
INCLUDE STRUCTURE ZIP1401OUT.
DATA: END OF I_OUTPUT.
DATA: BEGIN OF I_T156 OCCURS 0,
BWART TYPE T156-BWART,
SHKZG TYPE T156-SHKZG,
END OF I_T156.
DATA: BEGIN OF I_EKKO OCCURS 0,
EBELN TYPE EKKO-EBELN,
BSTYP TYPE EKKO-BSTYP,
BSART TYPE EKKO-BSART,
LIFNR TYPE EKKO-LIFNR,
EKORG TYPE EKKO-EKORG,
WAERS TYPE EKKO-WAERS,
END OF I_EKKO.
DATA: BEGIN OF I_EKPO OCCURS 0,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
TXZ01 TYPE EKPO-TXZ01,
MATKL TYPE EKPO-MATKL,
MENGE TYPE EKPO-MENGE,
NETPR TYPE EKPO-NETPR,
PEINH TYPE EKPO-PEINH,
KO_PRCTR TYPE EKPO-KO_PRCTR,
END OF I_EKPO.
DATA: BEGIN OF I_MARC OCCURS 0,
MATNR TYPE MARC-MATNR,
WERKS TYPE MARC-WERKS,
MAABC TYPE MARC-MAABC,
EKGRP TYPE MARC-EKGRP,
END OF I_MARC.
DATA: I_MATLMOVE_TMP LIKE I_MATLMOVE OCCURS 0.
DATA: I_EKKO_TMP LIKE I_EKKO OCCURS 0.
DATA: I_EKPO_TMP LIKE I_EKPO OCCURS 0.
DATA: I_MARC_TMP LIKE I_MARC OCCURS 0.
DATA: BEGIN OF I_MBEW OCCURS 0,
MATNR TYPE MBEW-MATNR,
BWKEY TYPE MBEW-BWKEY,
VPRSV TYPE MBEW-VPRSV,
VERPR TYPE MBEW-VERPR,
STPRS TYPE MBEW-STPRS,
END OF I_MBEW.
DATA: BEGIN OF I_T024 OCCURS 0,
EKGRP TYPE T024-EKGRP,
EKNAM TYPE T024-EKNAM,
END OF I_T024.
DATA: BEGIN OF I_LFA1 OCCURS 0,
LIFNR TYPE Z_LFA1-LIFNR,
NAME1 TYPE Z_LFA1-NAME1,
END OF I_LFA1.
DATA: BEGIN OF I_PRCTN OCCURS 0,
PRCTR TYPE M_PRCTN-PRCTR,
MCTXT TYPE M_PRCTN-MCTXT,
END OF I_PRCTN.
$$----
$$ Variables defintions
$$----
DATA V_FILE_CNT TYPE I.
DATA V_LASTRUN_DATE LIKE SY-DATUM.
data v_lastrun_time like sy-uzeit.
data v_lastrun_time_n_date(30).
DATA V_NAME LIKE TVARV-NAME.
DATA V_TEMP1(10) TYPE P DECIMALS 4.
$$----
$$ Constants definitions
$$----
CONSTANTS: C_VPRSV_S(1) TYPE C VALUE 'S',
C_VPRSV_V(1) TYPE C VALUE 'V',
C_SHKZG_H(1) TYPE C VALUE 'H'.
Definitions needed for ALV-grid-processing
type-pools: slis,
sscr.
Variables defintions
data: v_restrict type sscr_restrict,
v_assn type sscr_***,
v_opt_list type sscr_opt_list.
ALV types
Field catalog with field descriptions.
data: i_fieldcat_alv type slis_t_fieldcat_alv,
i_list_comments type slis_t_listheader,
v_list_comments like line of i_list_comments,
i_events type slis_t_event,
Sort criteria for first list display.
lt_sort_fieldcat type slis_t_sortinfo_alv,
ls_sort_fieldcat type slis_sortinfo_alv,
v_layout type slis_layout_alv,
v_fieldcat_alv like line of i_fieldcat_alv,
v_events like line of i_events,
v_repid like sy-repid,
v_variant like disvariant,
wa_variant like disvariant,
wa_variant_save type c,
wa_exit type c,
wa_repid like sy-repid.
Constants definitions
constants: c_x(1) type c value 'X',
c_alv_subtotals_summary type slis_formname
value 'ALV_SUBTOTALS_SUMMARY',
c_top_of_page type slis_formname value 'F_TOP_OF_PAGE',
c_a(1) type c value 'A'.
$$----
$$ Select-options and parameters
$$----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-003.
SELECT-OPTIONS : S_WERKS FOR T001W-WERKS,
S_EKORG FOR T024E-EKORG,
S_LIFNR FOR LFA1-LIFNR,
S_MATNR FOR MARA-MATNR,
S_BWART FOR T156-BWART,
S_EBELN FOR EKKO-EBELN,
S_BSTYP FOR T161-BSTYP NO INTERVALS,
S_BSART FOR T161-BSART NO INTERVALS.
PARAMETERS: P_WAERS LIKE T001-WAERS DEFAULT 'USD' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK E WITH FRAME.
PARAMETERS: P_FILE AS CHECKBOX,
P_REPORT AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK E.
selection-screen begin of block file01 with frame.
PARAMETERS: P_FILEID(6).
PARAMETERS: P_LF_01 LIKE FILETEXTCI-FILEINTERN
DEFAULT 'Z_IP1401_RECEIPT_EXTRACT',
P_PF_01 LIKE V_FILENACI-FILEEXTERN.
selection-screen end of block file01.
SELECTION-SCREEN BEGIN OF BLOCK DT WITH FRAME.
selection-screen skip 1.
SELECTION-SCREEN COMMENT 1(65) TEXT-D00.
PARAMETERS: P_DATE LIKE SY-DATUM.
selection-screen skip 1.
SELECTION-SCREEN END OF BLOCK DT.
selection-screen begin of block sb with frame.
selection-screen skip 1.
selection-screen comment 10(65) text-X00.
selection-screen skip 1.
selection-screen comment 10(65) text-X01.
selection-screen skip 1.
selection-screen comment 10(65) text-X02.
selection-screen end of block sb.
$$----
$$ initialization.
$$----
initialization.
PERFORM GET_FILE_NAME USING P_LF_01 P_FILEID '' CHANGING P_PF_01.
$$----
$$ At Selection-Screen.
$$----
At Selection-Screen.
IF P_FILE IS INITIAL AND P_REPORT IS INITIAL.
MESSAGE E100.
endif.
If not p_lf_01 is initial.
PERFORM GET_FILE_NAME USING P_LF_01 P_FILEID '' CHANGING P_PF_01.
endif.
$$----
$$ Start-of-selection.
$$----
Start-of-selection.
IF P_FILE = 'X'.
PERFORM OPEN_DATASETS.
ENDIF.
CLEAR V_LASTRUN_DATE.
CONCATENATE SY-CPROG P_FILEID INTO V_NAME.
IF P_DATE IS INITIAL.
PERFORM GET_LASTRUN_DATE.
ELSE.
V_LASTRUN_DATE = P_DATE.
ENDIF.
PERFORM SELECT_T156.
PERFORM SELECT_ZVMATLMOVE.
IF NOT I_MATLMOVE[] IS INITIAL.
PERFORM SELECT_SUPPORTING_DATA.
PERFORM PROCESS_DATA.
ENDIF.
Prepare the data to display the report as ALV GRID.
perform process_alv_grid.
$$----
$$ End-of-selection.
$$----
End-of-selection.
to change the sorting sequence for the output
SORT I_OUTPUT BY MATNR BUDAT MJAHR.
IF P_FILE = 'X'.
PERFORM WRITE_TO_FILE.
ENDIF.
IF P_REPORT = 'X'.
PERFORM WRITE_TO_REPORT.
ENDIF.
Perform Close_datasets.
PERFORM UPDATE_TVARV.
PERFORM ZSDN0004_PRINT_SELECT_OPTIONS
USING SY-CPROG ' '.
PERFORM FINAL_STATS.
$$----
$$ Top-of-page.
$$----
Top-of-page.
FORMAT COLOR 2.
PERFORM ZBSN0001_STANDARD_HEADER USING SPACE SYST-TITLE SPACE SPACE.
FORMAT COLOR OFF.
*Top-of-page.
form f_top_of_page.
clear v_list_comments.
refresh i_list_comments.
v_list_comments-typ = 'H'.
move: text-h01 to v_list_comments-info.
append v_list_comments to i_list_comments .
clear v_list_comments .
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_list_comments
I_LOGO =
I_END_OF_LIST_GRID =
endform. "f_top_of_page.
$$----
$$ Form Open_Datasets.
$$----
*Form Open_Datasets.
perform open_file using p_pf_01 'OUTPUT ' 'TEXT '.
*Endform.
$$----
$$ Form GET_LASTRUN_DATE
$$----
FORM GET_LASTRUN_DATE.
Get the last run date from TVARV
SELECT SINGLE LOW FROM TVARV
INTO TVARV-LOW
WHERE NAME = V_NAME
AND TYPE = 'P'
AND NUMB = 0.
IF SY-SUBRC NE 0.
If it does not exist then a full refresh will be sent
ELSE.
V_LASTRUN_DATE = TVARV-LOW+0(8).
ENDIF.
ENDFORM.
$$----
$$ Form SELECT_T156
$$----
FORM SELECT_T156 .
Get all of the info on the movement types that will be selected
SELECT BWART "Movement Type
SHKZG "Debit/Credit Indicator
FROM T156
INTO TABLE I_T156
WHERE BWART IN S_BWART.
ENDFORM. " SELECT_T156
$$----
$$ Form SELECT_ZVMATLMOVE
$$----
FORM SELECT_ZVMATLMOVE .
Get Material Document, Year of Material Doc, Item in Material Doc,
PO number, PO line item, Posting Date, Movement Type, Plant,
Purchasing Org, Material Group, Material number, Vendor Id,
Currency Key, Quantity Recieved, UOM, Storage location from View of
Material Doc Header and Items to the internal table I_MATLMOVE
SELECT MBLNR
MJAHR
BUDAT
ZEILE
BWART
MATNR
WERKS
LGORT
LIFNR
WAERS
MENGE
MEINS
EBELN
EBELP
PRCTR
FROM ZVMATLMOVE
INTO TABLE I_MATLMOVE
WHERE BUDAT >= V_LASTRUN_DATE
AND BWART IN S_BWART
AND MATNR IN S_MATNR
AND WERKS IN S_WERKS
AND LIFNR IN S_LIFNR
AND EBELN IN S_EBELN.
ENDFORM. " SELECT_ZVMATLMOVE
$$----
$$ Form SELECT_SUPPORTING_DATA
$$----
FORM SELECT_SUPPORTING_DATA .
I_MATLMOVE_TMP[] = I_MATLMOVE[].
SORT I_MATLMOVE_TMP BY EBELN.
DELETE ADJACENT DUPLICATES FROM I_MATLMOVE_TMP COMPARING EBELN.
Get Purchasing org, Currency, Account No, Purchasing doc category,
Purchasing Document Type from Purchasing Document Header table
SELECT EBELN "Purchasing Document Number
BSTYP "Purchasing document category
BSART "Purchasing Document Type
LIFNR "Account Number of the Vendor
EKORG "Purchasing Organization
WAERS "Currency Key
FROM EKKO
INTO TABLE I_EKKO
FOR ALL ENTRIES IN I_MATLMOVE_TMP
WHERE EBELN = I_MATLMOVE_TMP-EBELN
AND EKORG IN S_EKORG
AND BSART IN S_BSART
AND BSTYP IN S_BSTYP.
CLEAR I_MATLMOVE_TMP.
REFRESH I_MATLMOVE_TMP.
I_MATLMOVE_TMP[] = I_MATLMOVE[].
SORT I_MATLMOVE_TMP BY EBELN EBELP.
DELETE ADJACENT DUPLICATES
FROM I_MATLMOVE_TMP COMPARING EBELN EBELP.
Get the material group and the net price from the PO Line item
SELECT EBELN "Purchasing Document Number
EBELP "Item Number of Purchasing Document
TXZ01 "Short text
MATKL "Material Group
MENGE "Purchase order quantity
NETPR "Net price in purchasing document
PEINH "Price unit
KO_PRCTR "Profit Center
FROM EKPO
INTO TABLE I_EKPO
FOR ALL ENTRIES IN I_MATLMOVE_TMP
WHERE EBELN = I_MATLMOVE_TMP-EBELN
AND EBELP = I_MATLMOVE_TMP-EBELP.
CLEAR I_MATLMOVE_TMP.
REFRESH I_MATLMOVE_TMP.
I_MATLMOVE_TMP[] = I_MATLMOVE[].
SORT I_MATLMOVE_TMP BY MATNR WERKS.
DELETE ADJACENT DUPLICATES
FROM I_MATLMOVE_TMP COMPARING MATNR WERKS.
Get the Purchasing Group from the Plant Data for Material table
SELECT MATNR "Material Number
WERKS "Plant
MAABC "ABC indicator
EKGRP "Purchasing Group
FROM MARC
INTO TABLE I_MARC
FOR ALL ENTRIES IN I_MATLMOVE_TMP
WHERE MATNR = I_MATLMOVE_TMP-MATNR
AND WERKS = I_MATLMOVE_TMP-WERKS.
Get the standard price from the Material Valuation table
SELECT MATNR "Material Number
BWKEY "Valuation area
VPRSV "Price Control Indicator
VERPR "Moving Average Price
STPRS "Standard Price
FROM MBEW
INTO TABLE I_MBEW
FOR ALL ENTRIES IN I_MATLMOVE_TMP
WHERE MATNR = I_MATLMOVE_TMP-MATNR
AND BWKEY = I_MATLMOVE_TMP-WERKS.
IF NOT I_MARC[] IS INITIAL.
I_MARC_TMP[] = I_MARC[].
SORT I_MARC_TMP BY EKGRP.
DELETE ADJACENT DUPLICATES
FROM I_MARC_TMP COMPARING EKGRP.
Get the Buyer name from the purchasing groups table
SELECT EKGRP "Purchasing Group
EKNAM "Description of purchasing group
FROM T024
INTO TABLE I_T024
FOR ALL ENTRIES IN I_MARC_TMP
WHERE EKGRP = I_MARC_TMP-EKGRP.
ENDIF.
IF NOT I_EKKO[] IS INITIAL.
I_EKKO_TMP[] = I_EKKO[].
SORT I_EKKO_TMP BY LIFNR.
DELETE ADJACENT DUPLICATES
FROM I_EKKO_TMP COMPARING LIFNR.
Get the Vendor name from the Vendor Master (General Data subset)
SELECT LIFNR "Account Number of Vendor or Creditor
NAME1 "Name 1
FROM Z_LFA1
INTO TABLE I_LFA1
FOR ALL ENTRIES IN I_EKKO_TMP
WHERE LIFNR = I_EKKO_TMP-LIFNR.
ENDIF.
IF NOT I_EKPO[] IS INITIAL.
I_EKPO_TMP[] = I_EKPO[].
SORT I_EKPO_TMP BY KO_PRCTR.
DELETE ADJACENT DUPLICATES
FROM I_EKPO_TMP COMPARING KO_PRCTR.
I_MATLMOVE_TMP[] = I_MATLMOVE[].
SORT I_MATLMOVE_TMP BY PRCTR.
DELETE ADJACENT DUPLICATES
FROM I_MATLMOVE_TMP COMPARING PRCTR.
End of SIR 301081
Get the Profit center name from the Generated view for matchcodeID
PRCT-N
SELECT PRCTR "Profit Center
MCTXT "Search term for matchcode search
FROM M_PRCTN
INTO TABLE I_PRCTN
FOR ALL ENTRIES IN I_EKPO_TMP
WHERE PRCTR = I_EKPO_TMP-KO_PRCTR.
FOR ALL ENTRIES IN I_MATLMOVE_TMP
WHERE PRCTR = I_MATLMOVE_TMP-PRCTR.
ENDIF.
CLEAR: I_MATLMOVE_TMP,
I_EKKO_TMP,
I_EKPO_TMP,
I_MARC_TMP.
REFRESH: I_MATLMOVE_TMP,
I_EKKO_TMP,
I_EKPO_TMP,
I_MARC_TMP.
ENDFORM. " SELECT_SUPPORTING_DATA
$$----
$$ Form PROCESS_DATA
$$----
FORM PROCESS_DATA .
SORT I_EKKO BY EBELN.
SORT I_MARC BY MATNR WERKS.
SORT I_EKPO BY EBELN EBELP.
SORT I_MBEW BY MATNR BWKEY.
SORT I_T024 BY EKGRP.
SORT I_LFA1 BY LIFNR.
SORT I_PRCTN BY PRCTR.
Loop the internal I_MATLMOVE and move the corresponding values to
the internal table I_OUTPUT
LOOP AT I_MATLMOVE.
CLEAR V_TEMP1.
Move the Purchasing document category, Purchasing Document Type,
Account Number of the Vendor , Purchasing Organization from table
Purchasing Document Header to the internal table I_OUTPUT
CLEAR I_EKKO.
READ TABLE I_EKKO WITH KEY EBELN = I_MATLMOVE-EBELN
BINARY SEARCH.
IF SY-SUBRC EQ 0.
I_OUTPUT-BSTYP = I_EKKO-BSTYP.
I_OUTPUT-BSART = I_EKKO-BSART.
I_OUTPUT-LIFNR = I_EKKO-LIFNR.
I_OUTPUT-EKORG = I_EKKO-EKORG.
Move the Vendor name from view Vendor Master(General Data subset)
to the internal table I_OUTPUT
CLEAR I_LFA1.
READ TABLE I_LFA1 WITH KEY LIFNR = I_EKKO-LIFNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
I_OUTPUT-LIFNR1 = I_LFA1-LIFNR.
I_OUTPUT-NAME1 = I_LFA1-NAME1.
ENDIF.
ENDIF.
Move the ABC indicator,Purchasing Group from table Plant Data for
Material to the internal table I_OUTPUT
CLEAR I_MARC.
READ TABLE I_MARC WITH KEY MATNR = I_MATLMOVE-MATNR
WERKS = I_MATLMOVE-WERKS
BINARY SEARCH.
IF SY-SUBRC EQ 0.
I_OUTPUT-MAABC = I_MARC-MAABC.
I_OUTPUT-EKGRP = I_MARC-EKGRP.
Move the Buyer name from table Purchasing Group into the internal
table I_OUTPUT
CLEAR I_T024.
READ TABLE I_T024 WITH KEY EKGRP = I_MARC-EKGRP
BINARY SEARCH.
IF SY-SUBRC EQ 0.
I_OUTPUT-EKNAM = I_T024-EKNAM.
ENDIF.
ENDIF.
Move the Material Description, Material Group, Purchase order qty,
Net price in purchasing doc, Profit Center from the table
Purchasing Document Item to the internal table I_OUTPUT
CLEAR I_EKPO.
READ TABLE I_EKPO WITH KEY EBELN = I_MATLMOVE-EBELN
EBELP = I_MATLMOVE-EBELP
BINARY SEARCH.
IF SY-SUBRC EQ 0.
I_OUTPUT-TXZ01 = I_EKPO-TXZ01.
I_OUTPUT-MATKL = I_EKPO-MATKL.
I_OUTPUT-MENGE1 = I_EKPO-MENGE.
I_OUTPUT-KO_PRCTR = I_EKPO-KO_PRCTR.
Convert to the currency of the input parameter
PERFORM CONVERT_CURRENCY USING I_EKKO-WAERS
P_WAERS
I_EKPO-NETPR
CHANGING I_EKPO-NETPR.
V_TEMP1 = I_EKPO-NETPR / I_EKPO-PEINH.
Deleting commas to the purchase order quantity
IF I_OUTPUT-MENGE1 IS NOT INITIAL.
PERFORM DELETE_COMMAS CHANGING I_OUTPUT-MENGE1.
SHIFT I_OUTPUT-MENGE1 RIGHT CIRCULAR.
CONDENSE I_OUTPUT-MENGE1 NO-GAPS.
SHIFT I_OUTPUT-MENGE1 RIGHT DELETING TRAILING SPACE.
ENDIF.
Move the Profit Center name (text) from Generated view for
matchcode ID PRCT-N to the internal table I_OUTPUT
CLEAR I_PRCTN.
Begin of SIR 301081
READ TABLE I_PRCTN WITH KEY PRCTR = I_EKPO-KO_PRCTR
BINARY SEARCH.
READ TABLE I_PRCTN WITH KEY PRCTR = I_MATLMOVE-PRCTR
BINARY SEARCH.
End of SIR 301081
IF SY-SUBRC EQ 0.
I_OUTPUT-MCTXT = I_PRCTN-MCTXT.
ENDIF.
ENDIF.
Move the Standard Price from table Material Valuation to the
internal table I_OUTPUT
CLEAR I_MBEW.
READ TABLE I_MBEW WITH KEY MATNR = I_MATLMOVE-MATNR
BWKEY = I_MATLMOVE-WERKS
BINARY SEARCH.
IF SY-SUBRC EQ 0.
To check the Price control indicator
S for Standard Price
V for Moving price
IF I_MBEW-VPRSV EQ C_VPRSV_S.
Convert to the currency of the input parameter
PERFORM CONVERT_CURRENCY USING I_EKKO-WAERS
P_WAERS
I_MBEW-STPRS
CHANGING I_MBEW-STPRS.
I_OUTPUT-STPRS = I_MBEW-STPRS.
ELSEIF I_MBEW-VPRSV EQ C_VPRSV_V.
Convert to the currency of the input parameter
PERFORM CONVERT_CURRENCY USING I_EKKO-WAERS
P_WAERS
I_MBEW-VERPR
CHANGING I_MBEW-VERPR.
I_OUTPUT-STPRS = I_MBEW-VERPR.
ENDIF.
ENDIF.
Move the PO number, Material Document, Year of Material Doc,
Item in Material Doc, PO line item, Plant, Material Number,
Vendor Id, UOM, Currency Key, Movement Type, Storage location,
Profit Center from view View of Material Doc Header and Items
to the internal table I_OUTPUT
I_OUTPUT-EBELN = I_MATLMOVE-EBELN.
I_OUTPUT-MBLNR = I_MATLMOVE-MBLNR.
I_OUTPUT-MJAHR = I_MATLMOVE-MJAHR.
I_OUTPUT-ZEILE = I_MATLMOVE-ZEILE.
I_OUTPUT-EBELP = I_MATLMOVE-EBELP.
I_OUTPUT-WERKS = I_MATLMOVE-WERKS.
I_OUTPUT-MATNR = I_MATLMOVE-MATNR.
I_OUTPUT-LIFNR = I_MATLMOVE-LIFNR.
I_OUTPUT-MEINS = I_MATLMOVE-MEINS.
I_OUTPUT-WAERS = P_WAERS.
I_OUTPUT-BWART = I_MATLMOVE-BWART.
I_OUTPUT-LGORT = I_MATLMOVE-LGORT.
I_OUTPUT-KO_PRCTR = I_MATLMOVE-PRCTR.
WRITE I_MATLMOVE-BUDAT TO I_OUTPUT-BUDAT.
Multiply amt and qty by -1 if the movement type is a credit
CLEAR I_T156.
READ TABLE I_T156 WITH KEY BWART = I_MATLMOVE-BWART.
IF I_T156-SHKZG = C_SHKZG_H.
V_TEMP1 = V_TEMP1 * -1.
I_MATLMOVE-MENGE = I_MATLMOVE-MENGE * -1.
WRITE I_MATLMOVE-MENGE TO I_OUTPUT-MENGE UNIT I_MATLMOVE-MEINS.
PERFORM DELETE_COMMAS CHANGING I_OUTPUT-MENGE.
SHIFT I_OUTPUT-MENGE RIGHT CIRCULAR.
CONDENSE I_OUTPUT-MENGE NO-GAPS.
SHIFT I_OUTPUT-MENGE RIGHT DELETING TRAILING SPACE.
ELSE.
WRITE I_MATLMOVE-MENGE TO I_OUTPUT-MENGE UNIT I_MATLMOVE-MEINS.
PERFORM DELETE_COMMAS CHANGING I_OUTPUT-MENGE.
ENDIF.
Formatting the PO unit price
I_OUTPUT-NETPR = V_TEMP1.
SHIFT I_OUTPUT-NETPR RIGHT CIRCULAR.
CONDENSE I_OUTPUT-NETPR NO-GAPS.
SHIFT I_OUTPUT-NETPR RIGHT DELETING TRAILING SPACE.
APPEND I_OUTPUT.
CLEAR I_OUTPUT.
ENDLOOP.
ENDFORM. " PROCESS_DATA
$$----
$$ Form WRITE_TO_FILE
$$----
*FORM WRITE_TO_FILE.
LOOP AT I_OUTPUT.
V_FILE_CNT = V_FILE_CNT + 1.
TRANSFER I_OUTPUT TO P_PF_01 LENGTH 312.
ENDLOOP.
*ENDFORM.
$$----
$$ Form WRITE_TO_REPORT
$$----
*FORM WRITE_TO_REPORT.
PERFORM WRITE_HEADINGS.
LOOP AT I_OUTPUT.
WRITE : / I_OUTPUT-MBLNR.
WRITE I_OUTPUT-MJAHR.
WRITE I_OUTPUT-ZEILE.
WRITE I_OUTPUT-EBELN.
WRITE I_OUTPUT-EBELP.
WRITE I_OUTPUT-BUDAT.
WRITE I_OUTPUT-WERKS.
WRITE I_OUTPUT-EKORG.
WRITE I_OUTPUT-MATKL.
WRITE I_OUTPUT-MATNR.
WRITE I_OUTPUT-EKGRP.
WRITE I_OUTPUT-LIFNR.
WRITE I_OUTPUT-NETPR.
WRITE I_OUTPUT-WAERS.
WRITE I_OUTPUT-MENGE.
WRITE I_OUTPUT-MEINS.
WRITE I_OUTPUT-MENGE1.
WRITE I_OUTPUT-MAABC.
WRITE I_OUTPUT-STPRS.
WRITE I_OUTPUT-TXZ01.
WRITE I_OUTPUT-EKNAM.
WRITE I_OUTPUT-LIFNR1.
WRITE I_OUTPUT-NAME1.
WRITE I_OUTPUT-KO_PRCTR.
WRITE I_OUTPUT-MCTXT.
WRITE I_OUTPUT-BSTYP.
WRITE I_OUTPUT-BSART.
WRITE I_OUTPUT-BWART.
WRITE I_OUTPUT-LGORT.
ENDLOOP.
NEW-PAGE.
*ENDFORM.
$$----
$$ Form Close_Datasets.
$$----
*Form Close_Datasets.
Perform Close_file using p_pf_01.
*Endform.
$$----
$$ Form UPDATE_TVARV
$$----
*FORM UPDATE_TVARV.
TVARV-NAME = V_NAME.
TVARV-TYPE = 'P'.
TVARV-NUMB = 0.
TVARV-LOW = SY-DATLO.
MODIFY TVARV.
*ENDFORM.
$$----
$$ Form FINAL_STATS
$$----
*FORM FINAL_STATS.
WRITE: / 'FINAL STATS:'(018).
WRITE: /'--------------'.
IF P_FILE = 'X'.
WRITE: / 'File Created - '(015), P_PF_01.
WRITE: / 'Nbr of Records written to the file - '(016).
WRITE: V_FILE_CNT.
ELSE.
WRITE: / 'No File Created.'(017).
ENDIF.
SKIP.
IF P_DATE IS INITIAL.
WRITE: / 'Last rundate before this run - '(001), V_LASTRUN_DATE.
ENDIF.
WRITE: / 'New Last rundate - '(002) , SY-DATLO.
*ENDFORM.
$$----
$$ Form CONVERT_CURRENCY
$$----
FORM CONVERT_CURRENCY USING P_IN_WAERS
P_OUT_WAERS
P_IN_AMT
CHANGING P_OUT_AMT.
IF P_IN_WAERS = P_OUT_WAERS.
P_OUT_AMT = P_IN_AMT.
ELSE.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = P_IN_AMT
FOREIGN_CURRENCY = P_IN_WAERS
LOCAL_CURRENCY = P_OUT_WAERS
type_of_rate = c_type
IMPORTING
LOCAL_AMOUNT = P_OUT_AMT
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2.
ENDIF.
ENDFORM.
$$----
$$ Form DELETE_COMMAS
$$----
FORM DELETE_COMMAS CHANGING P_AMT.
DO.
REPLACE ',' WITH SPACE INTO P_AMT.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
ENDDO.
CONDENSE P_AMT NO-GAPS.
SHIFT P_AMT RIGHT DELETING TRAILING SPACE.
ENDFORM. "DELETE_COMMASENDFORM.
$$----
$$ Form WRITE_HEADINGS
$$----
*FORM WRITE_HEADINGS.
ULINE.
FORMAT COLOR 1.
WRITE 'Matl Doc. '(004).
WRITE 'Year'(005).
WRITE 'Item'(006).
WRITE 'PO Nbr '(007).
WRITE 'Item '(008).
WRITE 'Post Date '(009).
WRITE 'Plnt'(010).
WRITE 'POrg'(011).
WRITE 'Matl Grp '(012).
WRITE 'Material '(013).
WRITE 'PGp'(014).
WRITE 'Vendor '(019).
WRITE ' Price '(020).
WRITE 'Ckey'(021).
WRITE ' Qty'(022).
WRITE 'UOM'(023).
Begin of SIR 300589
WRITE 'Purchase order Qty'(024).
WRITE 'ABC Inventory Indicator'(025).
WRITE 'Standard Price'(026).
WRITE 'Material Desc'(027).
WRITE 'Buyer Name'(028).
WRITE 'Vendor ID'(029).
WRITE 'Vendor Name'(030).
WRITE 'Profit Center'(031).
WRITE 'Profit Center Name'(032).
WRITE 'Purchasing Doc Category'(033).
WRITE 'Purchasing Doc Type'(034).
WRITE 'Movement Type'(035).
WRITE 'Storage Location'(036).
End of SIR 300589
FORMAT COLOR OFF.
*ENDFORM.
Begin Of SIR-301278
*& Form process_alv_grid
To process the data for ALV GRID display
FORM process_alv_grid .
To Maintain Layout settings.
perform build_layout.
To display column headings.
perform fill_fieldcatalog.
To build the alv events for output
perform event_build.
To display the output in a ALV grid
perform grid_display.
ENDFORM. " process_alv_grid
*& Form build_layout
To fill the layout characteristics for output
FORM build_layout .
Move the report title
clear v_layout.
v_layout-detail_titlebar = sy-title.
ENDFORM. " build_layout
*& Form event_build
To build the alv events for output
FORM event_build .
refresh i_events.
clear v_events.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = i_events.
read table i_events with key name = slis_ev_top_of_page
into v_events.
if sy-subrc = 0.
move c_top_of_page to v_events-form.
modify i_events from v_events index sy-tabix.
endif.
read table i_events with key name = slis_ev_subtotal_text
into v_events.
if sy-subrc = 0.
move c_alv_subtotals_summary to v_events-form.
modify i_events from v_events index sy-tabix.
endif.
ENDFORM. " event_build
*& Form fill_fieldcatalog
This subroutine builds the fieldcatalog for output
FORM fill_fieldcatalog .
refresh: i_fieldcat_alv[].
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'MBLNR'.
v_fieldcat_alv-reptext_ddic = text-001.
v_fieldcat_alv-col_pos = 1.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'MJAHR'.
v_fieldcat_alv-reptext_ddic = text-002.
v_fieldcat_alv-col_pos = 2.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'ZEILE'.
v_fieldcat_alv-reptext_ddic = text-003.
v_fieldcat_alv-col_pos = 3.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'EBELN'.
v_fieldcat_alv-reptext_ddic = text-004.
v_fieldcat_alv-col_pos = 4.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'EBELP'.
v_fieldcat_alv-reptext_ddic = text-005.
v_fieldcat_alv-col_pos = 5.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'BUDAT'.
v_fieldcat_alv-reptext_ddic = text-006.
v_fieldcat_alv-col_pos = 6.
append v_fieldcat_alv to i_fieldcat_alv.
clear v_fieldcat_alv.
v_fieldcat_alv-tabname = 'I_OUTPUT'.
v_fieldcat_alv-fieldname = 'WERKS'.
v_fieldcat_alv-reptext_ddic = text-007.
v_fieldcat_aHi Priya,
u can download the data from dictionary table to ur pc/dektop by using three function modules.
1.DOWNLOAD
2.WS_DOWNLOAD
3.GUI_DOWNLOAD
i did a small prg.just hv a look and if it is possible change this to ur require output.
TABLES: VBAK,VBAP.
DATA: BEGIN OF I_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
ERNAM LIKE VBAK-ERNAM,
AUDAT LIKE VBAK-AUDAT,
VBTYP LIKE VBAK-VBTYP,
END OF I_VBAK.
DATA: BEGIN OF I_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
CHARG LIKE VBAP-CHARG,
MATKL LIKE VBAP-MATKL,
END OF I_VBAP.
DATA: BEGIN OF IT_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
ERNAM LIKE VBAK-ERNAM,
AUDAT LIKE VBAK-AUDAT,
VBTYP LIKE VBAK-VBTYP,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
CHARG LIKE VBAP-CHARG,
MATKL LIKE VBAP-MATKL,
END OF IT_VBAK.
SELECT VBELN ERDAT ERNAM AUDAT VBTYP FROM VBAK INTO TABLE I_VBAK.
SELECT VBELN POSNR MATNR CHARG MATKL FROM VBAP INTO TABLE I_VBAP.
SORT: I_VBAK BY VBELN,I_VBAP BY VBELN.
LOOP AT I_VBAK.
READ TABLE I_VBAP WITH KEY VBELN = I_VBAK-VBELN BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE I_VBAK-VBELN TO IT_VBAK-VBELN.
MOVE I_VBAK-ERDAT TO IT_VBAK-ERDAT.
MOVE I_VBAK-ERNAM TO IT_VBAK-ERNAM.
MOVE I_VBAK-AUDAT TO IT_VBAK-AUDAT.
MOVE I_VBAK-VBTYP TO IT_VBAK-VBTYP.
MOVE I_VBAP-POSNR TO IT_VBAK-POSNR.
MOVE I_VBAP-MATNR TO IT_VBAK-MATNR.
MOVE I_VBAP-CHARG TO IT_VBAK-CHARG.
MOVE I_VBAP-MATKL TO IT_VBAK-MATKL.
APPEND IT_VBAK.
ENDIF.
ENDLOOP.
*& IT ASKS THE CONFIRMATION FOR THE FILE FORMATE,WE CAN CHANGE THE FILENAME DYNAMICALLY(e.g DOC-TXT,XLS)
*CALL FUNCTION 'DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\C1.TXT'
FILETYPE = 'DAT' "ASC is also another format
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = '.TXT'
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = 'X'
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = 'X' "THIS WILL NOT SHOW THE FILE TYPE(DAT) WHILE CONFIRMATION OF FILE NAME
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
TABLES
DATA_TAB = IT_VBAK
FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
*& this will not ask for the confirmation for the filename
*CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\C2.DOC'
FILETYPE = 'DAT'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = IT_VBAK
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'D:\C5.DOC'
FILETYPE = 'ASC' "Separate Columns by Tabs in Case of ASCII Download
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = 'X' "Overwrite The File Only After
Confirmation
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = IT_VBAK
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if u need any more then i welcome u to clarify it.
reward points,if it is useful.
Maybe you are looking for
-
Unable to Release request number from DEV
Hi All, I want to release the request Number from Development,But it is not allowing me and saying :'You are not authorized to lock requests or tasks". please help how can i solve this problem as we Dont have Basis person. Target System is QAS. Anu,.
-
I am desesperate to understand how quite basic functions (just as one of many examples: how can I paste text, that I have formatted in MS Word and want to paste into a Forum Post-Entry?) can be done with the primitive and awful Text Editor used to en
-
How to do integration between Oracle 11g and SAP Data services
HI All, i want to load data from Oracle 11g data base to some other data bases. we have installed oracle 11g server in one machine and Data services server in one machine.we installed oracle 11g client in data services server machine . i cr
-
Accessing application module in a POJO for SOA architecural question
Hi, I have an architectural question. We have an app in jdev 11.1.1.1.0 that has app modules and jsf pages. It works great. I am of the thought that biz logic should not be contained in managed beans but in a POJO which is more tied to the model part
-
I tried the suggestions posted and nothing works. I have tried going to the mozilla extensions page but there is no "remove" button for sweetpacks. I have also tried "about:config" but when I make the change to have a different homepage (google), the