Wednesday 14 October 2020

Custom MetaNet creation using Function Modules – HRFORMS_METADATA

Initial Situation:

Initially our client was using the pay slips designed in Sap Script to display the results in the off-cycle workbench of payroll. However a new requirement was raised, where the client wanted to replace the Sap Script pay slip format (that looks like an sap script) with PDF forms. After much research, I have suggested the solution to be implemented with the use of HRFORMS which allows us to implement the solution by providing an interface that provides the payroll data to design the forms using Adobe forms or Smartforms platforms.

HRFORMS uses the default SAP_DEFAULT (SAP standard MetaNet) which fetches all the possible data of SAP standard HR master data, personnel time data, and payroll results. However, as our client has some project specific customizations in place, not all data could be retrieved using the standard SAP_DEFAULT MetaNet. Hence I had to proceed with using a custom MetaNet which can inherited all the properties of the default MetaNet along with providing a way to implement solution to retrieve customer specific data.

Solution:

Using the custom MetaNet I was able to accommodate the basis to fetch the data from customer specific Infotypes directly. However there were certain scenarios where the data was not stored directly in the Infotypes but the data was supposed to be displayed on the pay slip on the basis of some calculations/manipulations. Therefore I have come up with the idea of creating custom MetaNet using Funtion Module. This FM will contain all the necessary logic to perform the calculation/manipulatios and return the data to the MetaNet.

In this blog post, I have given all the information required to create a Custom MetaNet which uses the customer specific FM to retrieve all the required data.

Step 01: Go to TCODE HRFORMS_METADATA. Give the custom MetaNet name and choose the Country for which you would like to create the MetaNet and click on create.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Alternatively, you can also create a custom MetaNet by copying the standard SAP_DEFAULT by clicking on the copy button.

Step 02: In the maintenance screen of the MetaNet, we see there are three columns in left side MetaFigures, MetaDimensions, MetaStars and in the right side work-place for MetaNet.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 03: A custom meta dimension must be created. Click on the create button on the Meta Dimensions Column. Provide the name and description as per the requirement.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 04: Once the Meta Dimension has been created, each field you would like to use should be created under this meta Dimension node. These fields are called as Meta Fields. Right Click on the custom Meta Dimension and choose create field. Maintain the required name and description for the metafield.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

In this way create all the fields you would like to include in the meta dimension. The structure of the Meta Dimension after creating the meta fields will look as follows.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 05: Now create a custom FM using SE37 which contains all the logic to fetch the data relevant to these meta fields. These Meta Fields will be used as the Import, Changing or Tables parameters of this FM.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

IMP NOTE:

While creating the Tables parameter, create a structure and table type in SE11 including all the meta fields that you would like to use and this table type should be used in the Tables declaration.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Include all the respective code in the Source Code tab.

Step 06: Now double click on your Meta Dimension. On the right side window, in Attributes, maintain the FM name that you have created

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

In the MetaFields tab, maintain the field types. And to make a field as Key field just click on the squares left to the MetaField.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 07: Now create a MetaStar to map this Meta Dimension by clicking on create. Maintain the desired name and description.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Now drag and drop all MetaDimensions from the MetaDimensions column to the custom MetaStar.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 08: When all required MetaDimensions are inserted under then custom MetaStar then map the fields, on the right hand side of the screen. In the first MetaStar give type as Special Type A, Read Function as your FM name and Line structure as the structure you have created in SE11.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 09: Finally click on the work place of the MetaNet , Information about the MetaNet will display at the bottom of the window. Give the details as shown in the screen shot.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 10: Just drag and drop custom metaStar form the metaStar column to metaNet workplace.

SAP ABAP Development, SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Step 11: Save and exit form the MetaNet. This custom MetaNet can be now used in HRFORMS.

No comments:

Post a Comment