Script details

3
5/9/2015 SAPTechnical.COM Printing internal table contents dynamically http://www.saptechnical.com/Tutorials/SAPScripts/InternalTable/Display.htm 1/3 Search Home Trainings Quiz Tips Tutorials Functional Cert Q's Interview Q's Jobs Testimonials Advertise Contact Us SAP Virtual/Onsite Trainings Document Categories: ABAP TM Adobe Forms ABAPHR ALE & IDocs ALV BAPI BASIS BSP Business Objects Business Workflow CRM NEW LSMW SAP Script/Smart Forms BI/BW eXchange Infrastructure (XI) Enterprise Portals (EP) eCATT Object Oriented Programming SAP Query Userexits/BADIs WebDynpro for Java/ABAP TM Others What's New? ABAP Test Cockpit HOT SAP ABAP Pragmas Understanding SE32 (ABAP Text Element Maintenance) Creating an IDoc File on SAP Application Server Understanding “Advance with dialog” option of SAP Workflow SAP Workflow Scenario: Maintenance Notification Approval Enhancements to a standard class Working with Floating Field in Adobe Forms Inserting data from Internal Table into the step “Send Mail” Display GL Account long text using enhancement framework Differences between polymorphism in JAVA and ABAP Passing multiline parameters from an ABAP Class event to a Workflow container Concept of Reevaluate agents for active work items in SAP Workflow Dynamic creation of component usage in ABAP WebDynpro Adobe Forms: Display symbols like copyright and others Deactivate Hold functionality in Purchase order (ME21N) Quiz on OOABAP Add fields in FBL5N using BADIs Tutorial on Wide casting Defining a Range in Module Pool Program Copy fields from one structure/table into another structure/table Side Panel Usage in NWBC Contribute? Sample Specs What's Hot? Printing internal table contents dynamically in SAPScript By C.Lakshmi Prasanna, Stride Software Here is a Script in which an internal table is displayed with each record enclosed with a box and can grow according to the no of records given as the input. Scenario: 1 Here the input is given as 4 records And the Script is displaying the 4 records with each record enclosed in a Box Scenario: 2 Here the no of records chosen is 12 Observe that now 12 records are enclosed with the boxes. And now follows the listing of the code which is the Driver program for the above Script *&‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐* *& Report ZSCRIPT *&‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐* REPORT ZSCRIPT. data:begin of itab occurs 0, matnr type matnr,

Transcript of Script details

Page 1: Script details

5/9/2015 SAPTechnical.COM ­ Printing internal table contents dynamically

http://www.saptechnical.com/Tutorials/SAPScripts/InternalTable/Display.htm 1/3

  Search

Home   •  Tra inings  •  Quiz   •  Tips  •  Tutoria ls  •  Functiona l   •  Cert Q's  •   Inte rview  Q's  •  Jobs  •  Testimonia ls  •  Adve rtise   •  Contact Us

SAP Virtual/OnsiteTrainings

Document Categories:

ABAPTM

Adobe FormsABAP­HRALE & IDocsALVBAPIBASISBSPBusiness Objects Business WorkflowCRM NEWLSMWSAP Script/Smart FormsBI/BWeXchange Infrastructure (XI)Enterprise Portals (EP)eCATTObject Oriented ProgrammingSAP QueryUserexits/BADIsWebDynpro for Java/ABAPTM

Others

What's New?

ABAP Test Cockpit HOTSAP ABAP PragmasUnderstanding SE32 (ABAP TextElement Maintenance)Creating an IDoc File on SAPApplication ServerUnderstanding “Advance withdialog” option of SAP WorkflowSAP Workflow Scenario:Maintenance NotificationApprovalEnhancements to a standardclassWorking with Floating Field inAdobe FormsInserting data from Internal Tableinto the step “Send Mail”Display GL Account long textusing enhancement frameworkDifferences betweenpolymorphism in JAVA and ABAPPassing multiline parametersfrom an ABAP Class event to aWorkflow containerConcept of Re­evaluate agentsfor active work items in SAPWorkflowDynamic creation of componentusage in ABAP WebDynproAdobe Forms: Display symbolslike copyright and othersDeactivate Hold functionality inPurchase order (ME21N)Quiz on OOABAPAdd fields in FBL5N using BADIsTutorial on Wide castingDefining a Range in Module PoolProgramCopy fields from onestructure/table into anotherstructure/tableSide Panel Usage in NWBC

Contribute?

Sample Specs

What's Hot?

Printing internal table contents dynamically inSAPScript

By C.Lakshmi Prasanna, Stride Software

Here  is  a  Script  in  which  an  internal  table  is  displayed  with  each  recordenclosed with a box and can grow according to the no of records given asthe input.  

Scenario: 1  

Here the input is given as 4 records  

  

And the Script is displaying the 4 records with each record enclosed in a Box

Scenario: 2

Here the no of records chosen is 12  

Observe that now 12 records are enclosed with the boxes.  

  

And now  follows  the  listing  of  the  code which  is  the Driver  program  for  the  aboveScript 

*&‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐**& Report  ZSCRIPT*&‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*

REPORT  ZSCRIPT.

data:begin of itab occurs 0,      matnr type matnr,

Page 2: Script details

5/9/2015 SAPTechnical.COM ­ Printing internal table contents dynamically

http://www.saptechnical.com/Tutorials/SAPScripts/InternalTable/Display.htm 2/3

Web Dynpro for ABAP Tutorials 

Join the Mailing List

Enter name and email address below :

Name: 

Email: 

Subscribe   Unsubscribe 

GO

      maktx type maktx,     end of itab.

PARAMETERS:P_SNO TYPE I.data:i type i.move p_sno to i.

select matnr maktx from makt into table itab up to i rows.CALL FUNCTION 'OPEN_FORM' EXPORTING   FORM                              = 'ZSCRIPT_NEW' EXCEPTIONS   CANCELED                          = 1   DEVICE                            = 2   FORM                              = 3   OPTIONS                           = 4   UNCLOSED                          = 5   MAIL_OPTIONS                      = 6   ARCHIVE_ERROR                     = 7   INVALID_FAX_NUMBER                = 8   MORE_PARAMS_NEEDED_IN_BATCH       = 9   SPOOL_ERROR                       = 10   CODEPAGE                          = 11   OTHERS                            = 12          .IF sy‐subrc <> 0.* MESSAGE ID SY‐MSGID TYPE SY‐MSGTY NUMBER SY‐MSGNO*         WITH SY‐MSGV1 SY‐MSGV2 SY‐MSGV3 SY‐MSGV4.ENDIF.

loop at itab.CALL FUNCTION 'WRITE_FORM' EXPORTING   ELEMENT                        = 'ELEMENT '   FUNCTION                       = 'SET'   TYPE                           = 'BODY'   WINDOW                         = 'MAIN' EXCEPTIONS   ELEMENT                        = 1   FUNCTION                       = 2   TYPE                           = 3   UNOPENED                       = 4   UNSTARTED                      = 5   WINDOW                         = 6   BAD_PAGEFORMAT_FOR_PRINT       = 7   SPOOL_ERROR                    = 8   CODEPAGE                       = 9   OTHERS                         = 10          .IF sy‐subrc <> 0.* MESSAGE ID SY‐MSGID TYPE SY‐MSGTY NUMBER SY‐MSGNO*         WITH SY‐MSGV1 SY‐MSGV2 SY‐MSGV3 SY‐MSGV4.ENDIF.

endloop.

CALL FUNCTION 'CLOSE_FORM'          .IF sy‐subrc <> 0.* MESSAGE ID SY‐MSGID TYPE SY‐MSGTY NUMBER SY‐MSGNO*         WITH SY‐MSGV1 SY‐MSGV2 SY‐MSGV3 SY‐MSGV4.ENDIF.

Now the details of the LAYOUT  

The Script is designed with two pages FIRST and NEXT with a Main windowlaid on it  

(I have not enclosed the details of the steps involved in creating the Pages)  

In  the  following  Text  element  I  have  used  two  Box  commands  one  enclosingMATNR and one enclosing MAKTX but as they are both laid next to each other theout come is a single BOX enclosing MATNR and MAKTX with a vertical separator  

Line1:Sapscript­counter_0  is  the variable which  iam using  to dynamically  increasethe YPOS for drawing the BOX around each record as and when the  internal  tablegrows  

Line2:Element begins  

Line3:the first BOX command which is enclosing the MATNR,,observe that here thesapscript_counter  is  incremented  by  1  which  is  achieved  by  &SAPSCRIPT­COUNTER_0(+)&  

Line4: again  the sapscript­counter value  is  reinitialized  to  its previous value as  thenext  BOX  enclosing  MAKTX  has  to  be  at  the  same  YPOS  as  that  of  the  BOXenclosing MATNR  

Line5: another BOX command this time to enclose MAKTX  

Line6: writing of  the  internal  table variables MATNR and MAKTX to enable them tobe displayed on the output  

Text Element  

MAIN

1.DEFINE &SAPSCRIPT­COUNTER_0& = ­1

2.ELEMENT

3.BOX YPOS &SAPSCRIPT­COUNTER_0(+)& LN WIDTH '2' CM HEIGHT '1' LN    FRAME  10  TW  DEFINE  4.&SAPSCRIPT­COUNTER_0&  =  &SAPSCRIPT­COUNTER_0(­)&

Page 3: Script details

5/9/2015 SAPTechnical.COM ­ Printing internal table contents dynamically

http://www.saptechnical.com/Tutorials/SAPScripts/InternalTable/Display.htm 3/3

5.BOX  YPOS  &SAPSCRIPT­COUNTER_0(+)&  LN    XPOS  '2'CM  WIDTH  '10'  CMHEIGHT '1'LN  FRAME 10 TW

6.&itab­matnr&                         &itab­maktx&  

I am also giving the screen shot for the text element MAIN in Character editor  

  

I  have omitted  all  the  regular  steps  involved  to  build  the  LAYOUT(like  creation  ofPAGES, PAGE WINDOWS,WINDOWS,PARAGRAPH ,CHARACTER) to come outas  an  entity  just  to  avoid  the  clutter  and  focus  on  the  utilization  of  SAPSCRIPT­COUNTER variable.

Please send us your feedback/suggestions at [email protected] 

Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us  

© SAPTechnical.COM. All rights reserved.All product names are trademarks of their respective companies. SAPTechnical.COM is in no way affi l iated with SAP AG.

SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver, and and any other SAP trademarks are registered trademarks of SAP AG in Germany and in several other countries.Every effort is made to ensure content integrity. Use information on this site at your own risk.

Graphic Design by Round the Bend Wizards