Change variable value

HI,

I do not know how to address this issue…
On my SAP automation I need to run same process many times…
A varbale “ID” 1,2,3
A varible “numberOfDays” is equal to either 1 day or 2 days
When the ID is 1 and the numberOfDay value is 1 … then is has to run the whole process and finish… and go to next ID.
when its reading next ID 2 and numberOfDay value is 2 … then same process have to run 2 time and in the first time it has to give value under SAP (Period) the last date to month (coming from SN) like “31.03.2020” finish and then it has to run the same process 2nd time but this time it has to give 2nd last date of month as “30,03,2020” and finished the process.

It look simple but im stuck on how i can replace the date in same process and do i need to use copy of whole process 2 time or what. can someone help.

1 Like

@Palaniyappan can you help on that… thanks

1 Like

We can use a WHILE Loop where we can set the counter value based on ID
That is like This

counter < Id

Where counter is a variable of type int32 with default value as 0 defined in the variable panel

And before while loop use a assign activity and define the value for counter as 0 before the current one is been processed in the while loop

And to reduce the date we can use a simple expression to reduce the initial date value one by one like this
str_output = DateTime.ParseExact(datevalue.ToString,”dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-counter).ToString(“dd.MM.yyyy”)

Cheers @Latif

@Palaniyappan

Thank you sir While Loop is working…
But i still have issue with minus 1 day from the DATE…
secondLastDate is variable type String but have also tried with changing type to system.double but not working,
image

1 Like

@Doanh

Can you help with this issue?

@Latif

I cannot view your picture clearly, but strFratraedDatoSn is “31.03.2020” , right?
in that case, you have to use the format “dd.MM.yyyy” (format with point character), not “dd,MM,yyyy” (format with comma)

One more thing,
.AddDays(-strFratraedDatoSn)

→ it must be
.AddDays(-1)

2 Likes

yes strFratraedDatoSn is “31.03.2020”.

You were almost done
Mention the expression like this in assign activity
second_LastDate= DateTime.ParseExact(strFratetedDate.ToString,”dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd.MM.yyyy”)

I hope I would have misspelled name of the variable
Make sure you mention as per yours

This would work for sure
Kindly let for any queries or clarification

Cheers @Latif

2 Likes

Thanks @Palaniyappan the solution was solved by the @Doanh which corrected my typing mistake.
Thanks to both of you for the help.

Cheers…

2 Likes

Cheers @Latif

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.