SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




Install SAP Free


SAP Smartforms Table Parameter in Form Routine

Smartform developers use Form Routines just like ABAP functions to reuse common ABAP codes for specific purposes. A form routine can be called within SAP Smartform code blocks and help ABAP developer with a clear readable code. Although it is easy to pass parameters to a Smartform Form Routine, passing internal tables sometimes causes compile errors.

I'ld like to share a tip with ABAP and Smartform developers how they can pass internal tables to a Smartform Form Routine for calculations in this tutorial.

As a sample case, I'll try to pass pricing condition details in a KOMV internal table to my sample Smartform Form Routine.

In Smartform Global Data, I have defined TKOMV as table variable using TYPE TABLE OF type assignment with KOMV associated type.

TKOMV TYPE TABLE OF KOMV

In the Initialization code block, I've called RV_PRICE_PRINT_REFRESH and PRICING_GET_CONDITIONS functions to get pricing conditions and store them in global variable tkomv table.

CALL FUNCTION 'PRICING_GET_CONDITIONS'
 EXPORTING
  comm_head_i = komk
 TABLES
  tkomv = tkomv.

Now copy and paste following form routine codes in current SAP Smartform Form Routines tab as a new form routine.

FORM CALCITEMDISCOUNT
 USING lwa_vbap TYPE vbap
  tkomv TYPE TABLE OF komv
 CHANGING lv_discount TYPE kawrt.

*** ABAP CODE here reading tkomv table parameter for discount calculation
ENDFORM.

In an ABAP code block, use the following form call for above Smartform form routine as follows

PERFORM calcitemdiscount
 USING
  gwa_vbap
  tkomv
 CHANGING
 lv_discount.

Unfortunately when I compile or activate Smartform document, the following error message is displayed preventing the Smartform to activate successfully.

@8O@ DISCOUNT Different number of parameters in FORM and PERFORM (routine: CALCITEMDISCOUNT, number of formal parameters: 5, number of actual

Solution requires a simple trick. First of all ABAP developers will realize that in Form Routine definition the ABAP code is not parsed correctly although the Check tool in Form Routine tab did not throw an exception.

First, go to Types tab in Smartform Global Definitions (under Global Settings node) and define a new type as table type of target structure.

Custom Type declaration for Form Routine in Smartform

TYPES tkomv2 TYPE TABLE OF komv.

Now we can replace the table parameter in form routine definition with this new table type definition as follows. Only change the parameter definition, leave remaining ABAP code unchanged.

FORM CALCITEMDISCOUNT
 USING lwa_vbap TYPE vbap
  tkomv TYPE tkomv2
 CHANGING lv_discount TYPE kawrt.

*** ABAP CODE here reading tkomv table parameter for discount calculation
ENDFORM.

After above change is completed, you will be able to activate Smartform successfully and make PERFORM form routine calls within other ABAP code blocks in the Smartform document.






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/smartforms-table-parameter-in-form-routine.aspx)
SAP Invoice Output ZZZZ is not Defined
Email Spool Request using SAPOffice - Spool to PDF
How to Debug SmartForms - Debugging SAP SmartForm in ABAP ?
SAP Invoice Output Determination Analysis for Not Created Output Message
SAP Smartforms - How to Call Smartform within ABAP Program
SAP Smartforms Table for Sales Order and Invoice Outputs
SAP Smartforms Tutorial - How to Create Smartform
SAP Smartforms Tutorial - Create Smartforms Example
SAP Smartforms Tutorial - Table Calculations using Count
SAP Smartforms Tutorial - Table Calculations using Sum Total
SAPScript Transaction Codes
Adobe Forms Table Header is Missing After Second Page
Free Adobe LiveCycle Designer Download
Change Output Condition Records
Convert Smartform to PDF in Print Preview Mode
Export SAP Data to Fixed Length Text File
Message no XS826: Cannot process message; no node determined for 76550052
Complex Conditions in SAP Smartform with AND/OR
How to Spell Numbers using ABAP Spell_Amount Function Module
Delete Entries in NAST Table using RSCLNAST ABAP Program
How to Export IDOC as Excel and Save as Local File from WE02 Transaction
Export SAP Spool Requests as PDF using SP01 Transaction
How to Find Output Determination Procedure for a Billing Document
How to Disable Word Editor in SAP Smartform Text
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Print SAP Outputs From Two Printers at the Same Time
Get Proforma Invoice from Commercial Invoice in ABAP
SAP Output Management - Create New SAP Output Type
SAP Purchase Order Tables, Transaction Codes and Output
Graphics White Background Displayed Grey on SAP Smartform Output
SE63 Smartform Translation and Export using SLXT Program
SAP Smartform Runtime Error CX_SY_CONVERSION_NO_NUMBER
Window MAIN does not fit onto page PAGE (height)
SAP Smartforms Table Parameter in Form Routine
Trigger Output Re-Determination for Billing Documents
VF31 SAP Transaction to Reprocess Billing Output Messages
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table


Copyright © 2004 - 2019 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems