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

PLEASE HELP.

Former Member
0 Likes
566

hi guys,

Please help i have to develop this object.

i have a selection screen P_DATE:----


TYPE SY-DATUM.

Starting with the input parameter P_DATE, determine month MM and year YYYY and select all records (with all fields) from the table TCURR using the following criteria:

TCURR-KURST = 'TCL'.

TCURR-GDATU = ' DATE FALLS WITHIN THE MONTH OF THE SELECTION SCREEN PARAMETER'.

1. For each entry selected, check that one and only one entry exists for each month, both for the current month (taken from the parameter), as well as for all months starting from January of the current year. Please note - to do this, the program must take into account all key fields of table TCURR (KURST, FCURR, TCURR, GDATU), as multiple combinations of currencies exist within the table TCURR. See the example below.

Example: suppose the following entries are present in table TCURR:

 TCL GBP EUR 31.03.2006

 TCL GBP EUR 28.02.2006

 TCL GBP EUR 31.01.2006

 TCL CAD EUR 31.03.2006

 TCL CAD EUR 28.02.2006

 TCL CAD EUR 30.01.2006

 TCL CAD EUR 31.01.2006

 TCL USD EUR 31.03.2006

 TCL USD EUR 28.02.2006

If the selection parameter = 20060331, the program should first select the 3 'TCL' entries with validity dates during the month of March. Then, for each entry, it should check that one and only one entry exists for each month, starting from January of the current year, for the given exchange rate combination.

 Following this logic, the first entry to be processed, combination GBP / EUR, is OK, and processing to calculate the "average rate" can continue. However, the second entry to be processed, combination CAD / EUR, is in error, as two entries for this combination exist for the month of January. This entry should therefore be skipped, and output in the report's processing log.

 Finally, the third and final entry to be processed, combination USD / EUR, is also in error, as no entry is found for this currency combination for the month of January.

PLEASE HELP.

4 REPLIES 4
Read only

Former Member
0 Likes
537

Hi Ahmed ,

1 First Thing select all the records of TCURR into an internal table .

2 . Second thing selects records based on input date into another internale table .

Now start the loop of internal table with step 2 ..

Within that read internal table first with month of Jan of current month .

if sy-subrc = 0.

proceed with month = month + 1.

read the table again .

if sy-subrc = 0.

then this is valid record .

but if any of if condition fails then that is not valid record and delete the record from ur second internal table.

Example as below.

Loop at itab2 .

do month times.

perform read_table_itab1 using rc month .

if rc <> 0.

delete itab2.

else.

month = month + 1.

enddo.

endloop.

Please reward if useful .

Read only

Former Member
0 Likes
537

hi Ahmed,

1. take the month & year in seperate var for comparison.

2. then select all the record in a itab.

3. seperate it with comparing the date.

with regards,

S.Barane

Read only

andreas_mann3
Active Contributor
Read only

Former Member
0 Likes
537

hi ahmed pls try this code

tables : tcurr.

data : begin of itab occurs 0,

KURST like tcurr-kurst,

FCURR like tcurr-fcurr,

TCURR like tcurr-tcurr,

GDATU like tcurr-gdatu,

end of itab.

data : itab1 like itab occurs 0 with header line.

DATA : WTAB LIKE ITAB.

parameter : p_date like sy-datum.

data : rep_of_mon type i,

counter_of_month type i,

diff(2) type n,

month(2) type n.

month = p_date+4(2).

DIFF = MONTH.

*diff = month - 01.

itab-kurst = 'TCL'.

itab-fcurr = 'GBP'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060331'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'GBP'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060228'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'GBP'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060131'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'CAD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060331'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'CAD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060228'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'CAD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060130'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'CAD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060131'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'USD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060331'.

APPEND ITAB.

itab-kurst = 'TCL'.

itab-fcurr = 'USD'.

itab-tcurr = 'EUR'.

itab-gdatu = '20060228'.

APPEND ITAB.

sort itab by KURST FCURR TCURR GDATU descending.

itab1[] = itab[].

loop at itab1.

at new gdatu.

clear rep_of_mon.

counter_of_month = counter_of_month + 1.

endat.

rep_of_mon = rep_of_mon + 1.

if rep_of_mon gt 1.

delete itab where kurst = itab1-kurst and fcurr = itab1-fcurr and tcurr = itab1-tcurr.

endif.

MOVE-CORRESPONDING ITAB1 TO WTAB.

AT END of tcurr.

  • COUNTER_OF_MONTH = COUNTER_OF_MONTH - 1.

if counter_of_month ne diff.

delete itab where kurst = Wtab-kurst and fcurr = Wtab-fcurr and tcurr = Wtab-tcurr.

clear counter_of_month.

else.

clear counter_of_month.

endif.

endAT.

endloop.

regards

shiba dutta