How to automatically assign last month's cardinal number and second last month's cardinal number in a SAP field?

Hello!

in SAP t-code S_PL0_86000028 I need to insert the month’s cardinal number of the month previous to the current one and the number of the month that precedes the previous one.

For instance: today is December 6th 2021 and therefore I am launching the Bot in December (number 12). I need the BOT to insert in the field “Reporting Period to” number 11 (for November which is the previous month compared to December), and insert in the field “Comparison period to” number 10 (for October which is the previous month compared to November). Is there any way I can obtain these 2 outputs? Many thanks! Fabio

image

grafik

 today.AddMonths(-1).Month.ToString
 "11"
 today.AddMonths(-2).Month.ToString
 "10"

Thanks a lot Peter! that worked like a charm! Have a nice one, Fabio

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