This Space has blogs on various topics in the field of SAP. These blogs point out solutions to various technical and functional issues that consultants face during implementation or support of SAP Projects. Readers/followers are welcome to contribute to this space by emailing your content at bohra.mohammadi@gmail.com. You will be rewarded according to the topic/number of words/complexity of the topic/issue which are you addressing in your blog.
Wednesday, April 27
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP
Scenario- based on current date and month, user wants to select any month from the next 12 months. So as a developer you want to display in a list the next 12 months. For this you need to calculate next 12 months from the current date. Below written code does this and stores the next 12 months in a internal table. Later this internal table is bound with a context node to display next 12 months in a table or in a list (as user wishes) on the screen.
Technology used - Web Dynpro ABAP.
Programming language - ABAP.
Aim - calculate and store next 12 months from the current month in a internal table.
code is given below.
types : BEGIN OF ty_to_date,
name(20) type c,
value(20) type c,
END OF ty_to_date.
data : it_to_date type table of ty_to_date,
wa_to_date type ty_to_date.
data : date(12) type c.
data: year(4) type c,
month(2) type c,
day(2) type c.
data: imonths like sy-datum.
move sy-datum to imonths.
do 12 times.
imonths+4(2) = imonths+4(2) + 1.
imonths+6(2) = '01'.
if imonths+4(2) = 13.
imonths+4(2) = '01'.
imonths(4) = imonths(4) + 1.
endif.
year = imonths(4).
month = imonths+4(2).
day = imonths+6(2).
CONCATENATE month '.' year INTO date.
wa_to_date-name = date.
wa_to_date-value = date.
append wa_to_date to it_to_date.
enddo.
Bind the internal table to a Context Node to display list of next 12 months in a table or somwehere on the web dynpro ABAP Application screen.
target_node->Bind_Table( it_to_date ).
Target node has the same structure as the structure of the ty_to_date created above.
Related Articles :
Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - Validate Inputs in a web dynpro ABAP Application
Technology used - Web Dynpro ABAP.
Programming language - ABAP.
Aim - calculate and store next 12 months from the current month in a internal table.
code is given below.
types : BEGIN OF ty_to_date,
name(20) type c,
value(20) type c,
END OF ty_to_date.
data : it_to_date type table of ty_to_date,
wa_to_date type ty_to_date.
data : date(12) type c.
data: year(4) type c,
month(2) type c,
day(2) type c.
data: imonths like sy-datum.
move sy-datum to imonths.
do 12 times.
imonths+4(2) = imonths+4(2) + 1.
imonths+6(2) = '01'.
if imonths+4(2) = 13.
imonths+4(2) = '01'.
imonths(4) = imonths(4) + 1.
endif.
year = imonths(4).
month = imonths+4(2).
day = imonths+6(2).
CONCATENATE month '.' year INTO date.
wa_to_date-name = date.
wa_to_date-value = date.
append wa_to_date to it_to_date.
enddo.
Bind the internal table to a Context Node to display list of next 12 months in a table or somwehere on the web dynpro ABAP Application screen.
target_node->Bind_Table( it_to_date ).
Target node has the same structure as the structure of the ty_to_date created above.
Related Articles :
Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - Validate Inputs in a web dynpro ABAP Application
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
You are welcome to express your views here...