cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate the DATE based on the logic

Former Member
0 Kudos

Hi All,

I have requirement like this. File to Proxy Interface and the frequency of this interface is Monthly once.

File will be placed in FTP Folder, XI will pickup the file and update the Z-Table in ECC.

Here there is no Date field is coming from File, iam polulating the date from XI from Mapping using the Current date function.

Upto this its fine, but now the thing is

If the file comes on July-01-2009, i need to populate the Previous months Last date.( June-30-2009)

If the file comes on July-02-2009, i need to populate same as above.

If the file comes on June-20-2009, I should not process the file until the first day of the next month comes( After July-01-2009)

Is this is possible , please suggest me

Regards

Vamsi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Vamsi,

It seems there are two issues here:

> If the file comes on July-01-2009, i need to populate the Previous months Last date.( June-30-2009)

> If the file comes on July-02-2009, i need to populate same as above.

For this you can check todays date and if it is in between 1 and 20 then you can last month last date.

> If the file comes on June-20-2009, I should not process the file until the first day of the next month comes( After July-01-2009)

For this you need to schedule your file adapter accordingly. So it picks on first of every month. See this blog for scheduling:

/people/shabarish.vijayakumar/blog/2006/11/26/adapter-scheduling--hail-sp-19-

The bottom line is you need to pick your file or schedule your file adapter for the first week of every month. Then you have the current date as first week day date from XI server. Then with UDF we can populate the date accordingly in proxy.

If this design is ok then let us know so that somebody can help you for the udf for the date that needs to be send to Proxy in mapping.

Regards,

---Satish

Former Member
0 Kudos

Hi satish,

If i understood correct, let me explain it

We will schedule the sender adapter every month 1-7 dates, even though the file comes on 20th or any date the file wont be picked up.

So finally file will be picked up in between 1 and 7 dates of every month based on the CC Scheduling, based on the current date we have to get the previous months last date using the UDF.

This sounds good, can i get the UDF for this design

Regards

Former Member
0 Kudos

Vamsi,

Thats correct. So we both are on the same page.

So based upon this assumptions you need to have always last month date irrespective of the date (assuming it is picked in between 1 and 7). One thing I want to check is do you want the last month last day date or the last month any date?

Regards,

---Satish

Edited by: Satish Reddy on Jul 22, 2009 3:53 PM

Former Member
0 Kudos

Satish,

One thing I want to check is do you want the last month last day date or the last month any date?

Previous months last day only

Regards

Vamsi

Former Member
0 Kudos

In your ECC system, you have a Func module RP_CALC_DATE_IN_INTERVAL that adds/subtracts dates from the given date...

You can either call this FM from PI as RFC-lookup or can populate this value in ABAP proxy by calling the FM in the proxy..

There are other good FM's around date function that you might checkout as well in ECC.

-Siva Maranani

Former Member
0 Kudos

Hi Siva,

With out using calling the Function Module, can we do that using the UDF itself in XI mapping??

Please suggest me

Regards

Vamsi

former_member181962
Active Contributor
0 Kudos

Hi Vamsi,

I liked Siva's idea.

YOu can make use of function modules like: SG_PS_GET_LAST_DAY_OF_MONTH to get the last day of a month.

If you still want UDF code to get last day of the previous month, check these:

http://www.kodejava.org/examples/134.html

http://objectmix.com/java/713691-getting-lastday-previous-month.html

http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2008-07/msg00917.html

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

The FM that you have provided is giving the output as Last day of the current month

But i need Last day of Previous month

Regards

Vamsi

former_member181962
Active Contributor
0 Kudos

Hi Vamsi,

OKay..how about this:

RS_VARI_V_L_LAST_MONTH

Do not pass anything to P_INTRANGE

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

this is working fine.

Could you please direct me how can i proceed for RFC Lookup in XI Mapping

Regards

former_member181962
Active Contributor
0 Kudos

Hi Vamsi,

I don't suggest yo to call this FM from an UDF.

I would suggest to populate some dummy value in your XI mapping for your date field (Constant).Once the message reaches the inbound proxy, have your abap code all this FM and populate the date field before updating the ZTABLE.

Regards,

Ravi

Former Member
0 Kudos

Okay Ravi,

thats sounds good.

And also could you please provide the UDF for the same, with out using the any more function module if required to use it

The one which you provided the links for UDF's above making confuse me,

Regards

Vamsi

Former Member
0 Kudos

Hi Ravi,

This is my Proxy code in ECC, Could you please suggest me where i can insert the FM code

method ZZII_MI_MONTH_END_RATES_SAP~MI_MONTH_END_RATES_SAP.

        • **** INSERT IMPLEMENTATION HERE **** ****

*Data Declaration.

DATA: i_ztest TYPE TABLE OF ZNAE_TPM_RATES.

DATA: wa_ztest LIKE LINE OF i_ztest.

DATA: ls_rates_sap TYPE ZZMT_MONTH_END_RATES_SAP,

ls_month_end_rate TYPE ZZDT_MONTH_END_RATES_SAP,

lt_month_end_rates_sap TYPE ZZDT_MONTH_END_RATES_SAP_M_TAB,

ls_month_end_rates_sap TYPE ZZDT_MONTH_END_RATES_SAP_MONTH.

ls_rates_sap = input.

ls_month_end_rate = ls_rates_sap-MT_MONTH_END_RATES_SAP.

lt_month_end_rates_sap = ls_month_end_rate-MONTH_END_RATES_SAP.

LOOP AT lt_month_end_rates_sap INTO ls_month_end_rates_sap.

wa_ztest-ZWERKS = ls_month_end_rates_sap-DC.

wa_ztest-ZDATE = ls_month_end_rates_sap-date.

wa_ztest-ZRATE = ls_month_end_rates_sap-RATE.

APPEND wa_ztest TO i_ztest.

CLEAR wa_ztest.

ENDLOOP.

*Modify the Z table with the internal table.

MODIFY ZNAE_TPM_RATES FROM TABLE i_ztest.

COMMIT WORK.

endmethod.

Regards

Vamsi

former_member181962
Active Contributor
0 Kudos

OK, try this:

Use the following statement in the imports section of the UDF.

import java.util.Calendar;

IN the actual UDF, write this

java.util.Calendar c = java.util.Calendar.getInstance() ;
c.set(java.util.Calendar.DAY_OF_MONTH, 1) ;
c.add(java.util.Calendar.DAY_OF_MONTH, -1) ;

retrun java.text.DateFormat.getDateInstance().format(c.getTime(­)) ;

Regards,

Ravi

Former Member
0 Kudos

Hi Vamsi,

Create a UDF lastdaylastmonth with no input parameters. Then add this code:

Imports: java.;java.util.Calendar;*

Add this code:

java.util.Calendar c = java.util.Calendar.getInstance() ;

c.set(java.util.Calendar.DAY_OF_MONTH, 1) ;

c.add(java.util.Calendar.DAY_OF_MONTH, -1) ;

return (java.text.DateFormat.getDateInstance().format(c.getTime())) ;

Then map like this:

UDF(lastdaylastmonth) ---> Target

It return Jun 30, 2009 as an output. If you want to change the format you can use date function and can change the format. This is from the help what Ravi has provided

Regards,

---Satish

Former Member
0 Kudos

Hi Ravi and Satish,

This is working as good as i want ))

Thanks to ravi such a help from you

Regards

Vamsi

Former Member
0 Kudos

Hello,

I just tried the logic in Graphical mapping and i was succesfull. I wrote one small UDF to test for leap year. Apart from that i used few Fixed value mapping function to map month to actuall month names and days in a month.

Thanks.

Answers (0)