Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all 935 articles
Browse latest View live

How to debug a popup screen in SAP

$
0
0

1) Login to the system, click on the “Generate short cut” as shown below.

 

1.jpg

2) In the popup screen, give the below options and click on finish, confirmation message will be given and a short cut will be created on your desktop as shown below.

 

2.jpg

3.jpg

4.jpg

3) Now drag and drop this short cut to your popup screen, You will get a message in the bottom of the screen as Debugging switched on, then press on any action button in the pop up screen and a new debugger session will start immediately.

 

5.jpg

6.jpg


Creating radio buttons on popup window

$
0
0

                                                       create  radio buttons on popup window

 

 

1) Go to transaction SE37 and enter function module name 'K_KKB_POPUP_RADIO2'.

 

1.png 
 
2)   Enter details as mention and Execute.

 

2.png

How to create dynamic variable knowing reference tabname and fieldname

$
0
0

Original of this article is at (oprsteny.com)

 

 

If you want to create a variable during runtime knowing only the reference table name and its field name (in string form), you can achieve it following the code presented in this article

 

 

data:
* Names of the table and its field  g_tabname type tabname,  g_fieldname type fieldname,

* Data references to table and its field
  gr_data_line type ref to data,  gr_data_field type ref to data,

* Testing values
  g_test_value1 type char255 value '2021_error',  g_test_value2 type char255 value '2021'.

FIELD-SYMBOLS:
  <fs_table_line> type any,  <fs_table_line_field> type any.

* We want to create dynamic variable of type MARC-WERKS
g_tabname = 'MARC'.
g_fieldname = 'WERKS'.

*Create dynamic line of given table name
CREATE DATA gr_data_line TYPE (g_tabname).
ASSIGN gr_data_line->* to <fs_table_line>.

*Get reference to the required field
ASSIGN COMPONENT g_fieldname  OF STRUCTURE <fs_table_line> to <fs_table_line_field>.
CHECK sy-subrc = 0.

*Create dynamic variable with the same "structure" like the table field
CREATE DATA gr_data_field LIKE <fs_table_line_field>.

*Validation of data entered (not using either check or value table)
*just to make sure the value entered is accepted
<fs_table_line_field> = g_test_value1.
if <fs_table_line_field> = g_test_value1.  write:/ 'OK'.
else.  write:/ 'Error'.
endif.<fs_table_line_field> = g_test_value2.
if <fs_table_line_field> = g_test_value2.  write:/ 'OK'.
else.  write:/ 'Error'.
endif.

Adobe form Password protected with Java script

$
0
0


Summary:  Password protection for Adobe Form with Java Script

 

Approach:

1.Go to Transaction SFP

SFP.jpg

2. Create a form

Create a Form.jpg

 

3. Go to Layout and create a text on Master page as shown below

Decalre Text.jpg

 

4. Create Password check for adobe form

 

->Go to the Initialize event of DATA as shown below

Write Java code.jpg

 

->Write down below code


//Decalre variables
var a=1;
var b=2;
var password;


//Prompt for password from user to open the adobe form
password = xfa.host.response("Enter the Password","The title","123");

 

 

//Check for Correct password
{
if (password == "123")    // In this case Password id hard coded to 123
{
  xfa.host.messageBox("Right password","You Know right",3,0);
  a = 1;
  b = 1;
}
else
{
  xfa.host.messageBox("Wrong password","You know ur Wrong",1,1);
  a = 1;
  b = 2;
  password = xfa.host.response("Enter the Password","The title","123");
}
}
while( a != b );

 

 

5. Now execute the form

  -> Do not forget the mark Fillable of Form I/P as 'X'

Test form.jpg

 

Mark Fillable.jpg

 

and execute.

 

Now, Adobe form will ask for password as shown below

Fill pop for password.jpg

 

Till correct password is enetered this pop up will appear. We can download this form and try to open still password protection will be vaild.

 

 

Drawbacks:

->Password is harcoded, I do not how to check with an value from table or rule dynamically

->I ain't any good in Java scipt, hence could not hide password ( genrally it works with form calc)

How to find the extension structure of a given BAPI

$
0
0

For example lets take an example of BAPI_PO_CREATE1.

 

1) Find the package of the BAPI in which it is stored.

 

1.jpg

2) Goto SE11 and give BAPI_TE_* in the data type and press F4.

 

2.jpg

 

3) Click on structures

 

3.jpg

 

4) You will get a huge list of structures. click on new selection

4.jpg

5) In the pop up provide the package name from step 1 and press OK.

5.jpg

 

6) Now you will get a list of structures related to that BAPI in step1.

 

6.jpg

Printing QR Code with Zebra Printer through SAP Script

$
0
0

This document provides a procedure on how to Print a QR Code in Zebra Printer through SAP Script.


Procedures


1. Install Zebra Printer Device Type

2. Install Generic Printer on Client Computer

3. Design the QR Code using Zebra Designer

4. Coding SAP Script with Zebra ZPL code

5. Sample Output


Step by Step Procedures


1. Installing Zebra Printer Device Type


To install SAP Zebra printer device type, initiate the transaction command line SPAD.

 

 

 

Click on configuration from the menu and select output devices.


 

Click on change icon.

 

 

Click on create icon.

 

 

Enter the required parameters, Select LB_ZEB2 for the Device Type.

 

 

Use Front End Printing for the Access Method and save the configuration.

 

2. Install Generic Printer on Client Computer


Generic printer will be use in the client terminal to print the QR Code since we will use the Zebra ZPL code in our SAP Script.

 


 

Click on Add printer

 

 

Select Local Printer

 

 

Select Generic Printer.

 

3. Design the QR Code using Zebra Designer

 

Use the Zebra Designer to design the QR Code Labels.

 

 

From the Zebra Designer select the QR Code.

 

 

Enter the required parameters.

 

 

Generate the ZPL code by printing the code to a file as shown in the below figure.

 

Click on File->Print

 

 

 

Select print to file and click on print.

 

 

Enter the File Name of your file to save.

 

 

Copy the generated file and import to your SAP Script.

 

4.Coding SAP script with Zebra ZPL Code


Import the ZPL code in your SAP Scripts and put the required variable data.

 

 

 

5.Sample Output

 

 

Execute the Program.


 

 

Below is the output of the program when printed in the Zebra Printer using the Generic Printer as your windows printer driver

it will print the QR Code.

 

Self-Inner Join using SAP Quick Viewer (T-code SQVI)

$
0
0

Author : Biswanath Guha

 

 

Introduction : SAP Quick viewer tool is used to fetch data graphically without writing codes. It helps the end user to fetch data from a single table or inner joining multiple tables . It may be in Development , Quality or Production server. Main advantage is that no need to transport any query report. It does not ask for any Workbench Transport Request as it saves in local object at that server. T-code is SQVI.


Problem Description : Sometimes it requires to do self-inner join between a single table in SAP Quick Viewer tool.


Solution :Suppose, in SAP ISU enter a Premise to fetch the connection object from T1 aliased table and pass the connection object to T2 aliased table to fetch all Premise in the connected to that connection object. Means Connection object can have multiple premise.


  1. Enter T-code SQVI to open SAP Quick viewer.
  2. Enter a name of quick view 'ZTEST1' and press 'Create' Button.  
  3. Enter a Title and Comments . Then select data source as Table Join and click enter.
  4. Click on the 'Alias' button.  
  5. Click on 'Create' button.
  6. Enter the table name ( EBVS table) and alias name (say, T1) on the pop-up of 'Create Alias Table'.
  7. Now repeat step 5 and 6 to create another alias name (say, T2) of same table EVBS.
  8. Press 'Enter' or click Ok button.
  9. Click on insert table button to add table T1 and then T2.
  10. T1 and T2 will be automatically connected by Primary key (VSTELLE - Premise).
  11. Now right click on the link and delete the link if required.
  12. Select HAUS field from T1 table and drag and drop it to T2 table HAUS field, then both will be linked.
  13. Press back button .  
  14. In the List field selects sub-screen , add fields from the Available fields . Select Connection Object field and move it to left field in list. Select the Premise to display fields.
  15. Click on Selection fields.  
  16. Select Premise from possible selection fields.
  17. Select Sort sequence sub-screen and select fields if ascending or descending sorting is required.
  18. Click Save button and execute.
  19. Enter Premise XXXXX and output will be displayed in ALV List Viewer.


Conclusion : SAP Quick Viewer is a useful tool . In any environment, required data can be fetched from a single table or from various connected table by using inner join , self-inner join or left outer join.

Reading the HR Payroll results using Class and Methods (PRR, Payroll Results Reader class)

$
0
0

Rather than reading the payroll results in traditional way using FM's we can process the same using Payroll reader class which was designed to use with PNP logical database. SAP recommends that not to use GET PAYROLL event.  Instead sap had provided the below PRR class i.e. Payroll Results Reader class.

 

 

 

REPORT  ZHR_1.
 TABLES PERNR.
 ** Payroll results realted data declarations
 DATA: GO_PRR               TYPE REF TO CL_HRPAY99_PRR_4_PNP_REPS,       GT_PERNR_PR          TYPE H99_HR_PAY_RESULT_TAB.
 *** Field Symbols.
 FIELD-SYMBOLS: <PERNR_PR>   TYPE REF TO CL_HR_PAY_RESULT.
 START-OF-SELECTION.
 ** Create an instance to the payroll results reader class .   CONSTANTS: LV_CO_MOLGA(2) VALUE '40'.
 ** Generate/ Create an instance of payroll reader class.   CALL METHOD CL_HRPAY99_PRR_4_PNP_REPS=>GET_INSTANCE     EXPORTING       IM_PN_BEGDA     = PN-BEGDA       IM_PN_ENDDA     = PN-ENDDA       IM_MOLGA        = LV_CO_MOLGA       IM_PNPDISBD     = PN-BEGDA     IMPORTING       EX_PRR          = GO_PRR     EXCEPTIONS       INVALID_ENTRIES = 1       OTHERS          = 2.   IF SY-SUBRC <> 0.
 ** Error message can be raised   ENDIF.
 ******** GET PERNR EVENT **************
 GET PERNR.
 ********* START READING OF INDIVIDUAL EMPLOYEE PAYROLL RESULTS AFTER GET PERNR EVENT *************
 CALL METHOD GO_PRR->GET_PERNR_PAYR_RESULTS_ALLIN1     EXPORTING       IM_PERNR                      = PERNR-PERNR     IMPORTING       EX_PERNR_PAYROLL_RESULTS      = GT_PERNR_PR     EXCEPTIONS       COUNTRY_VERSION_NOT_AVAILABLE = 1       NO_AUTHORIZATION              = 2       NO_ENTRIES_FOUND              = 3       READ_ERROR                    = 4       OTHERS                        = 5.   IF SY-SUBRC <> 0.   ENDIF.
 *** Payroll results loaded in to GT_PERNR_PR based on the requirement like only regular, only offcycle you can process the results table.
 ** Identify only the regular payroll results.   LOOP AT GT_PERNR_PR ASSIGNING <PERNR_PR>.
 *     GO_PERNR_PR ?= <PERNR_PR>.     IF <PERNR_PR>->PERIOD-FPPER NE <PERNR_PR>->PERIOD-INPER OR <PERNR_PR>->PERIOD-FPPER NE PN-PAPER OR        <PERNR_PR>->PERIOD-FPPER EQ 'X' OR <PERNR_PR>->PERIOD-FPPER = '000000' .
 *      CLEAR <PERNR_PR>.        " Write own logic to mark and process the result record as required     ENDIF.   ENDLOOP.

 

Regards,

Mayure


Adobe Forms with Advanced Features

$
0
0

Adobe FORMS

Adobe Forms provides many good features which are not possible with other kind of forms.
So, Adobe Forms stands as very efficient alternative for the Smartforms for the next generation document services.

Adobe Life Cycle Designer is required for building form in the Adobe Forms. Adobe Forms is accessed by the
T-Code SFP.

 

Adobe Form Builder

T-Code SFP will navigate us to entry point for the Form Builder.

1.pngFigure 1: Adobe Form Builder

 

Form Interface


Every form requires an interface to be created first as because interface is the one through which we can get the required data based on the user inputs.

 

Step 1: Create Interface

To create an interface, check the Interface radio button, enter the interface name and click on create button.

1.png

Figure 2: Form Interface Creation

 

Enter the description for form interface, select interface type and click on the save button.

 

                                       1.png

Figure 3: Form Interface Description

 

 

 

STEP 2: Declare Interface Parameters

On creation of the interface the following default initial interface screen appears which is divided into different sections.

  • Form Interface
  • Global Definitions
  • Initialization
  • Current/Quantity Fields

1.pngFigure 4: Default Interface Screen

 

Form Interface consists of the parameters Import, Export and Exceptions which consists of default parameters as shown in the Figure 4.

Import – Used to receive inputs
Export – Used for providing output
Exceptions – Used to raise exceptions

 

Global Definitions consists of the parameters Global Data, Types and Field Symbols.

Global Data – Used to declare the data which can be accessed globally throughout the Form.
Types – Used to declare the types that can be used global throughout the interface.
Field Symbols – Used to declare the field symbols which can be accessed globally throughout the interface.

 

Initialization consists of the parameters Code Initialization and Form Routines.
Code Initialization – Used to write the regular code to retrieve the required data.
Form Routines – Used to write the performs which are used in the code initialization.

 

Currency/Quantity Fields consists of the parameter which is used to set the data type for the fields.

Create a new import parameter for the user to enter Personnel Number in the selection screen.

1.png

Figure 5: Create Import Parameter

 

Create a types parameter for the employee data.

 

1.png

Figure 6: Create Types Parameter

 

Create the global data parameters for personnel number, last name, first name and employees table.

                               1.png

Figure 7: Create Global Data

 

STEP 3: Code Initialization

In the Code Initialization, provide the import parameter as im_pernr and write the code to retrieve last name, first name based on the pernr entered.

1.png

Figure 8: Code Initialization

 

The toolbar button is used for the Pretty Printer and button above it is used for the Pattern in the Code Initialization.

Inorder to debug the interface the keyword BREAK-POINT can be used as there is no option of break-point directly.

 

Adobe Form

 

Every Interface is required with a form to display the data output in desired layout.

Step 1: Create Form

To create a form, check the Form radio button, enter the interface name and click on create button.

1.png

Figure 9: Form Creation

 

Enter the description for form, select associated interface and click on the save button.

                                    1.png

Figure 10: Assign Form Interface

 

Step 2: Maintain Data

On creation of the form following default initial form screen appears which is divided into different sections with the parameters created in the interface.

  • Import
  • Global Data
  • System Fields

1.png

Figure 11: Default Form Screen

 

Drag and drop the required parameters from the left hand side to the context in the right hand side. So that they will be available in the layout section.

                                1.png

Figure 12: Context Section

 

Where Conditions & Conditions can be written to filter the data based on a parameter.

                                  1.png

Figure 13: Where Conditions & Conditions

 

Step 3: Maintain Layout

Click on the layout tab to navigate to the form layout section. Layout button can also be used for the full screen layout.

1.png

Figure 14: Form Layout

 

The workspace consists of the various palettes and the layout section.

The Layout section is further divided into three sections

  • Design View
  • Master Pages
  • Preview PDF

 

Design View to used to design the regular output that is required to be displayed

Master Pages are used when content is required to be repeated in every page.

Preview PDF is used to see the preview of the layout designed.

 

Following are some of the palettes available in the layout.

 

·  Font Palette

·  Data View Palette

·   Hierarchy Palette

·  Tab Order Palette

·  Border Palette

·  Accessibility Palette

·   Layout Palette

·   Object Palette

 

In Master Pages section a content area is required, which can be designed in the Design Form section.

From standard tab of Object Library, Drag and drop a Text which is used as an heading in every page.

In the Font Palette necessary properties can be set to get the below output.

1.png

Figure 15: Font Palette

 

Drag and drop a Sub Form from the object library into the design view.

 

A subform can be moved from one place to other place by selecting the green rectangle at the top right of the subform as shown in the figure 16.

 

In the Data View Palette, drag and drop the required properties into the sub form.

1.png

Figure 16: Data View Palette

 

In Hierarchy Palette, select the pernr field which will hilight the field in the layout section which allows to edit the properties.

 

1.png

Figure 17: Hierarchy Palette

 

In Object Palette, Caption, Appearance, Value Type and Data Binding can be changed as shown in the figure 18.

 

1.png

Figure 18: Object Palette

 

In Layout Palette, Margins and Anchor Position (Position of the subform in the form) can be changed as shown in the figure 19.

1.png

Figure 19: Layout Palette

 

In Border Palette, Borders and Background color can be changed as shown in the figure 20.

1.png

Figure 20: Border Palette

 

We are now done with the basic layout design and now activate the interface by activate button.

 

Execute the form which navigates to the selection screen as shown in the figure 21.

1.png

Figure 21: Selection Screen

 

After executing the above screen, select the output device as LP01 and select the Print Preview button to get the PDF preview as shown in figure 22.

1.png

Figure 22: PDF Preview

 

 

With this creation of basic adobe form is completed.

 

Table Display

 

Now we will create the table display in the form.

Create another subform in the layout and drag and drop the table LT_EMPLOYEES from the data view into the subform.

1.png

Figure 23: Table Display

 

Select the subform in the Hierarchy and select the content as Flowed in the subform sub tab of object tab.

 

Flowed– Data will be overflowed to next page on increase of records
Positioned– Data will not be overflowed to next page

1.png

Figure 24: Table Properties

 

In the Binding sub tab besides setting the binding user can also mention the minimum, maximum and initial count of the rows in the table.

 

In the Row sub tab user can specify the type of row, whether a body row, header row or a footer row.

 

In the Pagination sub tab user can if the table need to move down when the above object is overflowed.

 

Patterns

 

Patterns are used to format the data displayed on the form.

 

Now we will restrict the pernr not to display only last 7 letters i.e, 6004187 instead of 06004187. This can be done using the patterns.

 

Select the pernr field from the hierarchy and click on the patterns under the object palette.

 

In the Pattern text box enter the pattern to format the pernr display as shown in the figure 25.

1.png

Figure 25: Pattern

 

Scripts

 

Scripts are used in the adobe forms to hide the subforms, to calculate the subtotals and totals of the table.

 

Select the pernr field in the hierarchy and write a script to hide the table when pernr is provided as null as shown in the figure 26.

1.png

Figure 26: Scripts

 

Scripts can be also used to do the form validations.

 

Finally the output of the developed adobe form looks as shown in the figure 27.

 

                            1.png

Figure 27: PDF Output

A basic help --- Working with smartform language translation

$
0
0

Below is a simple and basic help document regarding the language translation of Smartforms / any other objects in ABAP.

 

When I got a requirement in one my project to translate multiple smartforms from English to other other languages arabic and dutch. Based on my experience I am writing this document for reference purpose.

 

1. Before going to translate a smartform / its text module to any other language you first create in English / your logon language.

 

2. Once it is completed before going to translation you have to check that the required / target language was installed in SAP server. In an easy way you can check that from the SAP GUI Logon page by entering the language code. If it is not installed it will give you the error message as below screenshot.

 

Logon_language_error.png

 

3. If required language is not installed in the system , you may please ask basis team to install that language in SAP server. For installing the language in server it requires 3 to 4 hours of downtime.

 

4. Once language installation completed , Open the transaction code SE63 , Transalation environment tool to do the translation of smartform / or any other objects. If you had done the translation of an object into any other language that means when you login with that target language then the translated document will be available in that language. That means if you translated a smartform into arabic and if any user logged in with arab language then the smartform output will be in arabic and if the smartform is not translated into arabic already then only English language o/p only available (Created with English logon language).

 

5. Open SE63->Translation->ABAP Objects->Transport Object .  Give the object entry details of the smartform along with source and target language of translation as below and click EDIT.

 

 

SE63_1.png

 

6. After that it will list you the possible objects that can be translated and if you select the required it will open as split screen editor where on the top source language will open and in the below it will provide the space to translate in the target language as below . And what ever you enter in the target language it will be display in target language login.

 

SE63_2.png

 

7.  Click SAVE ACTIVATE(shift+f4) button to activate it and transport the request that generated here.

 

 

EOD.

 

Regards,

Mayure.

Taking SAP GUI screenshot automatically and send as attachment through mail programmatically

$
0
0

This document explains how screen shot of SAP GUI screen can be taken automatically (not using Prtsc manually )and sends it as mail attachment by ABAP program.


Requirement:Taking screenshot of GUI screen like shown below and send it as mail attachments through ABAP.

capture.png


Approach


1.      Use front end GUI service class to take screenshot – Method GET_SCREENSHOT of CL_GUI_FRONTEND_SERVICES.

         When you called this method, system will take screenshot of active screen and return screenshot data intern of hexadecimal values          (xstring).

capture.png

           As shown in above code, screenshot data is imported by image parameter


2.     Convert xstring data into binary data to send it as attachment – Use method XSTRING_TO_SOLIX  of class CL_BCS_CONVERT

capture.png

         LT_DOC_CONTENT contains binary data which will be used later to send as attachment in mail.


3.      Send screenshot as mail attachment – Use class CL_BCS to send mail with attachment.

        a)      Create persistent class reference for a mail send request

capture.png

    

       b)      Create Mail document to include body, attachment etc

capture.png

       Above code – Mail subject as ‘Project Status Info’. Mail body can be in I_TEXT parameter.

       For this example I not used any mail content.

      

     c)      Add screenshot as attachment to mail – Can be Attached as PNG,BMP, GIF, JPG etc format.

              Note screenshot content passed here.

capture.png

          Binary content of screenshot data LT_DOC_CONTENT which prepared in step1 and step2

          passed to I_ATT_CONTENT_HEX.


      d)      Attach mail document to send request.

capture.png

     e)      Attach sender and recipient address. Add sender, TO, CC, BC address to send request.


capture.png

   f)      Send Mail – Call send method to send mail with attachment

capture.png



Result :


capture.png

Email send with attachment


capture.png

Read GOS (Generic Object Service) Picture Attachments and Display it into Adobe Form

$
0
0

Abhijit MandalPurpose & Overview:There are lot of threads, wiki’s and blogs available about GOS. Reading and downloading GOS attachment and also we will find lots of article on how to attach a document into GOS.

 

But there are not many documents which describes the complete cycle of reading GOS object and display it into adobe form dynamically. The idea of this document is to build a complete cycle of reading a GOS attachment and then embed it into SAP Adobe form.

 

Limitations & Restrictions: This document is to read GOS picture attachments and embedding it into SAP adobe form. As, I have tried for reading a .PDF GOS attachment and embedding it into SAP Adobe form but as per my knowledge SAP doesn’t provide such solutions till now. So, this is restricted to picture format (.JPG, .GIF, .BMP and .PNG etc.). For (.TIFF & .TIF) picture format first we have to convert from .TIF to .JPG format.   

 

Business Requirement & Descriptions: In this document I will read GOS attachments which are quality certificates and display the quality certificates into SAP Adobe form. This is applicable for other transactions which have got generic object service.

 

Create a structure & table type which will be sent to SAP adobe form as an import parameter.

Image1.jpg

Create table type:

Image2.jpg

Building the program:

 

REPORT  zabhi_gos_attachment_read.

DATAlv_lgsystm    TYPE logsys,
       lv_line      
TYPE i,
       lv_input_len 
TYPE i,
       ls_connection
TYPE bdn_con,
       lv_docid     
TYPE so_entryid,
       lv_objkey    
TYPE swo_typeid,
       ls_doc_data  
TYPE sofolenti1,
       ls_certattach
TYPE ztst_itab,
       lv_string    
TYPE xstring.


DATAlt_connection TYPE STANDARD TABLE OF bdn_con,
       lt_content   
TYPE STANDARD TABLE OF solisti1,
       lt_cont_hex  
TYPE STANDARD TABLE OF solix,
       lt_attachment
TYPE ztst_tt_itab.

FIELD-SYMBOLS<lfs_connection> TYPE bdn_con.

 
CLEAR: lv_lgsystm,
       lv_input_len
,
       lv_line
.


* Build selection screen


SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_bo   TYPE bds_clsnam OBLIGATORY DEFAULT 'BUS2117',
            p_cert
TYPE qcpr-certno OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
* To Get own logical system


CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
     IMPORTING
      own_logical_system            
= lv_lgsystm
     EXCEPTIONS
      own_logical_system_not_defined
= 1
            OTHERS                                                = 2.
     IF sy-subrc <> 0.
     
CLEAR lv_lgsystm .
     ENDIF.

* Retrieves list of attachment (quality certificate images) details through BDS_GOS_CONNECTIONS_GET function module .


CLEAR lv_objkey.
MOVE p_cert TO lv_objkey.

CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
     EXPORTING
      logical_system    
= lv_lgsystm
      classname         
= p_bo
      objkey            
= lv_objkey

     TABLES
      gos_connections   
= lt_connection[]
     EXCEPTIONS
      no_objects_found  
= 1
      internal_error    
= 2
      internal_gos_error
= 3
     
OTHERS                         = 4.
     IF sy-subrc = 0.
     
SORT lt_connection .
     ENDIF.

LOOP AT lt_connection ASSIGNING <lfs_connection>.


     
TRANSLATE <lfs_connection>-docuclass TO UPPER CASE.
     
MOVE <lfs_connection>-loio_id TO lv_docid.

* Reading the content of the image file. Internal table lt_cont_hex is the converted binary format of the image is    generating.


CALL FUNCTION 'SO_DOCUMENT_READ_API1'
     
EXPORTING
           document_id                
= lv_docid
     
IMPORTING
           document_data              
= ls_doc_data
     
TABLES
            object_content            
= lt_content[]
            contents_hex              
= lt_cont_hex[]
     
EXCEPTIONS
            document_id_not_exist     
= 1
            operation_no_authorization
= 2
            x_error                   
= 3
           
OTHERS                                         = 4.
     
IF sy-subrc <> 0.
          
CLEAR ls_doc_data.
     
ENDIF.

CLEAR: lv_line, lv_input_len.

* The most important part is to get correct length. If you do not pass the correct length you image will not be displayed.
     DESCRIBE TABLE lt_cont_hex LINES lv_line.
   lv_input_len 
= lv_line * sy-tleng .

* Converting binary data to Xstring format

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
     
EXPORTING
           input_length 
= lv_input_len
           first_line   
= 0
           last_line    
= 0
     
IMPORTING
          
buffer                   = lv_string
     
TABLES
           binary_tab  
= lt_cont_hex
     
EXCEPTIONS
           failed      
= 1
          
OTHERS             = 2.
         IF sy-subrc <> 0.
     
CLEAR lv_string.
   
ENDIF.

* Now we need to convert the Xstring data to string data otherwise the image will not be shown.
ls_certattach
-certno = p_cert.

     CALL FUNCTION 'SSFC_BASE64_ENCODE'
     
EXPORTING
           bindata
= lv_string

     
IMPORTING
           b64data
= ls_certattach-f_string.
     
IF sy-subrc <> 0.
          
CLEAR ls_certattach-f_string.
     
ENDIF.

     
APPEND ls_certattach TO lt_attachment.
     
CLEAR ls_certattach.

ENDLOOP.

 

 


* To print the image into adobe form call below subroutine.


PERFORM f_sub_print_form USING lt_attachment.
*&---------------------------------------------------------------------*
*&      Form  F_SUB_PRINT_FORM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_sub_print_form  USING  p_gt_tab TYPE ztst_tt_itab.
     
DATA : ls_sfpoutputparams  TYPE sfpoutputparams,
            ls_docparams       
TYPE sfpdocparams,
            ls_pdf_file        
TYPE fpformoutput,
            lv_formname        
TYPE fpname VALUE 'ZTEST_DYNAMIC_PICTURE',
            lv_fmname          
TYPE funcname,
            lv_mseg            
TYPE  string,
            lv_w_cx_root       
TYPE  REF TO cx_root" Exception class


      ls_sfpoutputparams
-dest     = 'XX01'.
      ls_sfpoutputparams
-nodialog = 'X'.
      ls_sfpoutputparams
-preview  = 'X'.


     CALL FUNCTION 'FP_JOB_OPEN'
     
CHANGING
           ie_outputparams
= ls_sfpoutputparams
     
EXCEPTIONS
           cancel         
= 1
           usage_error    
= 2
           system_error   
= 3
           internal_error 
= 4
          
OTHERS          = 5.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.

     TRY .
     
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
          
EXPORTING
                i_name    
= lv_formname
          
IMPORTING
                e_funcname
= lv_fmname.

     
CATCH cx_root INTO lv_w_cx_root.
           lv_mseg
= lv_w_cx_root->get_text( ).
          
MESSAGE lv_mseg TYPE 'E'.

     ENDTRY.

     MOVE: sy-langu TO ls_docparams-langu.

     CALL FUNCTION lv_fmname
     
EXPORTING
           /1bcdwb/docparams 
= ls_docparams
           im_itab           
= p_gt_tab
     
IMPORTING
           /1bcdwb/formoutput
= ls_pdf_file
     
EXCEPTIONS
           usage_error       
= 1
           system_error      
= 2
           internal_error    
= 3
     
OTHERS             = 4.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.

     CALL FUNCTION 'FP_JOB_CLOSE'
     
*   IMPORTING
     
*     E_RESULT             =
     
EXCEPTIONS
           usage_error         
= 1
           system_error        
= 2
           internal_error      
= 3
          
OTHERS               = 4.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.


ENDFORM.                    " F_SUB_PRINT_FORM


Now build the simple form to test:


Go To SFP: Build an interface ZTEST_I_DYNAMIC_PICTURE and pass the import parameter in INPUT and OUTPUT parameter.

Image3.jpg

Now Build FORM Context.

image 4.jpg

Go to Layout:

Create one Image field into Design view and bind it with F_Sring which is the converted image in string format.


layout.jpg


Activate it.


Now execute your program. Enter the parameters. Business object and Object key. Here object key is the certificate Number and Business object 'BUS2117'.


If you choose different Business object then you have to give correct object key. To get correct object key you can check the business object in SWO1 transaction.


After executing the output is coming like below.

output.jpg

Reference: I don't want to mention particular documents but I take help on few threads on GOS and Adobe form in SCN to build this document.


Suggestion: Please feel free to suggest.

Useful SAP standard Demo & Sample programs for ABAP Beginners ( Keywords & Syntaxes)

$
0
0

Hi all,

 

I am here by taking opportunity to mention some SAP Standard demo programs for practicing and becoming expertise with ABAP programming techniques and syntaxes.

 

I started adding some programs and slowly will update the document slowly one by one And by the way all of this programs we can found all the demo programs in the package SABAPDEMOS .

 

 

 

S.NoProgram NameDescription
1DEMO_SELECTION_SCREEN_EVENTSDemo program for Selection screen Events
2DEMO_DATA_DATE_TIMEDate and Time Calculations
3DEMO_DATA_FUNCTIONMathematical Functions
4DEMO_DATA_STRINGProcessing Strings
5DEMO_DESCRIBE_FIELDDemonstration of DESCRIBE FIELD
6DEMO_DYNPROModule pool demo program
7DEMO_DYNPRO_AT_EXIT_COMMANDConditional Exit module (Exit form the screen having required fields)
8DEMO_DYNPRO_AUTOMATIC_CHECKSDemonstration of Automatic Entry Checks on Screens
9DEMO_DYNPRO_DROPDOWN_LISTBOXDemonstration of Dropdown List Boxes on Screens
10DEMO_DYNPRO_SUBSCREENSSubscreens
11DEMO_DYNPRO_TABCONT_LOOPTable Control with LOOP - ENDLOOP
12DEMO_DYNPRO_TABLE_CONTROL_2Table Control with LOOP AT ITAB
13DEMO_DYNPRO_VALUE_SELECTSAPBC470_OUTPUT_FORMATS
14DEMO_EXTRACT_AT_NEWControl Level Processing
15DEMO_INT_TABLES_COLLECTInserting Summarized Table Lines Using COLLECT
16DEMO_LEAVE_TO_LIST_PROCESSINGCalling Lists from Screens
17DEMO_LIST_AT_LINE_SELECTIONLine Selection with PICK
18DEMO_LIST_AT_USER_COMMANDThe AT USER-COMMAND Event
19DEMO_LIST_END_OF_PAGEFormatting the Page Footer & Header
20DEMO_LIST_FORMAT_COLOR_1Possible Colors in Lists
21DEMO_ABAP_OBJECTSComplete Demonstration for ABAP Objects
22DEMO_ABAP_OBJECTS_METHODSDemonstration of Methods in ABAP Objects
23DEMO_ABAP_OBJECTS_GENERALABAP Objects Demonstration
24DEMO_SELECTION_SCREEN_F1F1 Help on the Selection Screen
25DEMO_SELECTION_SCREEN_F4F4 Help on the Selection Screen
26RSDEMO_HTML_VIEWERHTML Viewer Demo Program
27DEMO_MESSAGESDemo Program to understand behaviour of messages with various types in different scenarios.
28BCALV_TREE_DNDALV Tree Demo Program using ABAP OO Concepts
29SAPMSDM1Development WorkBench Demos ( T.Code DWDM )
30SAPBC470_DEMOCall of an SAP Smart Form
31SAPBC470_FLOWD_LABELSLabels with SAP Smart Forms
32SAPBC470_FLOWD_LOOPSmartform example with loop
33SAPBC470_OUTPUT_FORMATSOutput Formats for SAP Smart Forms
34SAPBC470_PROGSCall of an SAP Smart Form
35SAPBC470_TABLD_TICKETTicket output with SAP Smart Forms
36SAPBC470_TEXTD_CAMDemo of Business Address Services (Smarforms)
37GRBUSG_3Demo Program for Learning Graphs ( 2D / 3D / 4D )

 

Regards,

Mayure

Infotype 2 enhancement for displaying Employee age based on the date of birth

$
0
0

First of all my glad wishes to SAP SDN for providing this platform for ABAPers mainly as this is the basic step to get into sap community for discussing.

 

THANKS TO MR.SRINIVAS K for giving this idea to present it on our platform.

 

In this cool sezn I want to write about a small introduction about infotype enhancement with a tiny example.

 

OBJECTIVE: Enhancement of Infotype 0002 for displaying age of Employee based on the date of birth entered in Single screen.

 

 

PROCEDURE STEPS:-

 

1. Open Tcode ' PM01 '  then select 'SINGLE SCREEN'.

2. Enter Infotype 0002 then click on ''GENERATE OBJECTS'.

STEP2.JPG

3. Popup will display with message that 'CI_P0002' doesn't exist. Do you want it create it? Click CREATE button.

 

STEP3.JPG

4.  Then Add a new field with name AGE and give the new custom data element which was created with datatype NUMC and lenght '2' .

     After that activate and Press F3 for to come back.

 

 

step4.JPG

 

5. press enter for the transport requests shown. You will be redirected to BADI implementation screen then click F3 to return to Infotype Enhancement.

 

6. Open new Session and open TCODE 'SE80' (OBJECT BROWSER) for editing the Infotype custom include field details i.e. values.

    Open program ' ZP000200 '  as below.

Step 6.JPG

 

7. Double click on Screen ' 0200 ' & go to change mode then (CTRL+F1) then Click on 'LAYOUT' (CTRL+F7) to enter into screen Painter.

    Double Click the properties of AGE input/output field and change the field attributes to 'OUTPUT ONLY' for display only purpose. Please refer the below screenshot.

Step 7.JPG

 

8. Activate the screen and exit to FLOWLOGIC . Then open PBO module ' MODULE_PBO_0002 '   write the below function module code to calculate and populate age on the screen as below.

 

** Function module to calculate the age based on the date of birth entered in screen.

  CALL FUNCTION 'HRCM_TIME_PERIOD_CALCULATE'

    EXPORTING

      BEGDA         = P0002-GBDAT

      ENDDA         = SY-DATUM

    IMPORTING

      NOYRS         = P0002-AGE      " AGE is the custom field name created at PM01

*    NOMNS         =

*    NODYS         =

    EXCEPTIONS

      INVALID_DATES = 1

      OVERFLOW      = 2

      OTHERS        = 3.

Step 8.JPG

 

9. Similarly add the above code in PAI module 'MODULE_PAI_0002' also and then activate the whole program by right-clicking on the program name in the left hand side window.

 

Step 9.JPG

 

10. Then EXIT from the SE80 & PM01 (Infotype enhancement) .


11. Open Tcode PA30 then open Infotype 0002 to check the implemented enhancement.

    The AGE field will get populated at both the PBO & PAI levels.

 

Step 11.JPG

 

This was the end of the story.

 

Keep Blogging.......

 

Regards,

Mayure.

Program to print Employee basic pay details using Interactive ALV Report.

$
0
0

Intoduction:

 

You often need to determine wage types and their amounts from infotype 0008 ( basic pay). Using the function modules we can evaluate all these wage types information.

 

Input :

 

We can give the Employee numbers or Payroll area etc in selection screen.

 

Output:

 

We will display all the selected employees basic detail i.e. pernr, empname, total all wage types amount & its currency using Interactive ALV.

 

1.JPG

 

If we click on any particular we will display the second page output using alv.

 

2.JPG

 

 

Below is the code snippet to achieve this one.  And use PNP database for this report program.

 

Code Snippet

*&---------------------------------------------------------------------*

*& Report  ZR_C101_CSD122 ( By using PNP Ldb )

*&

*&---------------------------------------------------------------------*

*& Report program to print the employee basic pay details ( Infotype 8)

*& Using ALV Interactive Reprot.

*&---------------------------------------------------------------------*

 

REPORT  ZR_C101_CSD122.

 

** Declaration Part

TYPE-POOLS SLIS.        " Type pools declaration for ALV fieldcat purpose.

TABLES PERNR.

 

INFOTYPES: 0001, 0002, 0007, 0008.

 

DATA: WA_PBWLA TYPE PBWLA,

      PBWLA TYPE TABLE OF PBWLA,

      IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

      IT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

 

DATA: BEGIN OF IT_PBWLA OCCURS 0,

        PERNR TYPE PERNR-PERNR,

        WAERS TYPE PBWLA-WAERS,

        LGART TYPE PBWLA-LGART,

        LGTXT TYPE T512T-LGTXT,

        BETRG TYPE PBWLA-BETRG,

        INDBW TYPE PBWLA-INDBW,

      END OF IT_PBWLA.

 

DATA: BEGIN OF IT_PAGE1 OCCURS 0,      " Internal table for First page ALV

       PERNR TYPE PERNR-PERNR,         " Which contains Emp no, Name, Hire date, Total All wage types amount

       EMPNAME(80) TYPE C,

       CURR TYPE PBWLA-WAERS,

       AMOUNT TYPE Q0008-SUMBB,

      END OF IT_PAGE1.

 

DATA: BEGIN OF IT_PAGE2 OCCURS 0,      " Internal table for Second page in ALV output

        PERNR TYPE PERNR-PERNR,

        LGART TYPE PBWLA-LGART,

        LGTXT TYPE T512T-LGTXT,

        WAERS TYPE PBWLA-WAERS,

        BETRG TYPE PBWLA-BETRG,

        INDBW TYPE PBWLA-INDBW,

      END OF IT_PAGE2.

 

DATA: BEGIN OF IT_T512T OCCURS 0,

        MOLGA TYPE T512T-MOLGA,

        LGART TYPE T512T-LGART,

        LGTXT TYPE T512T-LGTXT,

      END OF IT_T512T.

 

********** Start of selection event*****

START-OF-SELECTION.

 

** READ ALL THE WAGE TYPE DESCRIPTIONS .

 

  SELECT MOLGA LGART LGTXT FROM T512T

                           INTO TABLE IT_T512T

                           WHERE SPRSL = SY-LANGU.

 

  SORT IT_T512T BY LGART MOLGA.

** Get pernr event

GET PERNR.

 

** Read the latest record to header of infotype 8 internal table.

  RP-PROVIDE-FROM-LAST P0008 SPACE PN-BEGDA PN-ENDDA.

  IF PNP-SW-FOUND = 1.

** Call the function module to fill the employee all wage type details

    CALL FUNCTION 'RP_FILL_WAGE_TYPE_TABLE_EXT'

      EXPORTING

        BEGDA                        = P0008-BEGDA

        ENDDA                        = P0008-ENDDA

        INFTY                        = '0008'

        PERNR                        = PERNR-PERNR

      TABLES

        PP0001                       = P0001

        PP0007                       = P0007

        PP0008                       = P0008

        PPBWLA                       = PBWLA

      EXCEPTIONS

        ERROR_AT_INDIRECT_EVALUATION = 1

        OTHERS                       = 2.

    IF SY-SUBRC <> 0.

      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

 

 

** Get the total amount in basic pay infotype using the below function module.

 

    CALL FUNCTION 'HR_GET_TOTAL_AMOUNT_P0008'

      EXPORTING

        PERNR             = PERNR-PERNR

        P0008             = P0008

        P0001             = P0001

      IMPORTING

        AMOUNT            = IT_PAGE1-AMOUNT

        CURRENCY          = IT_PAGE1-CURR

      EXCEPTIONS

        NO_ENTRY_IN_T001P = 1

        NO_ENTRY_IN_T503  = 2

        OTHERS            = 3.

    IF SY-SUBRC <> 0.

      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

 

** Concatinate the first and last name of employee

    RP-PROVIDE-FROM-LAST P0002 SPACE PN-BEGDA PN-ENDDA.

 

    CONCATENATE P0002-NACHN P0002-VORNA INTO IT_PAGE1-EMPNAME.

** Append the total amount of all wage types amount to ALV first page internal table.

    IT_PAGE1-PERNR = PERNR-PERNR.

 

    APPEND IT_PAGE1.

 

** Append all employee basic pay records to a single internal table ( it_pbwla).

    LOOP AT PBWLA INTO WA_PBWLA.

      READ TABLE IT_T512T WITH KEY LGART = WA_PBWLA-LGART MOLGA = WA_PBWLA-MOLGA BINARY SEARCH.

      MOVE IT_T512T-LGTXT TO IT_PBWLA-LGTXT.

      MOVE-CORRESPONDING WA_PBWLA TO IT_PBWLA.

      MOVE PERNR-PERNR TO IT_PBWLA-PERNR.

      APPEND IT_PBWLA.

      CLEAR IT_PBWLA.

 

    ENDLOOP.

 

 

  ENDIF.

 

 

END-OF-SELECTION.

 

** CALL THE INTERACTIVE ALV GRID DISPLAY FUNCTION TO DISPALY THE ALL

** EMPLOYEE DETAILS WITH TOTAL WAGE TYPES AMOUNT , EMP NAME, EMP NO.

 

  PERFORM APPEND_FIELDCAT USING 'PERNR' 'EMP NO' 'X' '' .

  PERFORM APPEND_FIELDCAT USING 'EMPNAME' 'EMP NAME' '' '' .

  PERFORM APPEND_FIELDCAT USING 'CURR' 'CUR FORMAT' '' '' .

  PERFORM APPEND_FIELDCAT USING 'AMOUNT' 'TOTAL WAGE TYPES AMOUNT' '' '' .

 

 

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      I_CALLBACK_PROGRAM          = SY-REPID

*      I_CALLBACK_PF_STATUS_SET    = ' '

      I_CALLBACK_USER_COMMAND     = 'SECOND_PAGE'

*      I_CALLBACK_TOP_OF_PAGE      = ' '

*      IS_LAYOUT                   =

      IT_FIELDCAT      =      IT_FIELDCAT1[]

    TABLES

      T_OUTTAB                    = IT_PAGE1

    EXCEPTIONS

      PROGRAM_ERROR               = 1

      OTHERS                      = 2.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

 

 

 

*&---------------------------------------------------------------------*

*&      Form  APPEND_FIELDCAT

*&---------------------------------------------------------------------*

*      SUBROUTINE TO APPEND THE FIELDCATALOG FOR FIRST PAGE.

*----------------------------------------------------------------------*

*      -->P_0328   text

*      -->P_0329   text

*      -->P_0330   text

*      -->P_0331   text

*----------------------------------------------------------------------*

FORM APPEND_FIELDCAT  USING    VALUE(P_0328)

                               VALUE(P_0329)

                               VALUE(P_0330)

                               VALUE(P_0331).

  IT_FIELDCAT1-FIELDNAME = P_0328.

  IT_FIELDCAT1-SELTEXT_L = P_0329.

  IT_FIELDCAT1-HOTSPOT = P_0330.

 

  APPEND IT_FIELDCAT1.

  CLEAR IT_FIELDCAT1.

 

ENDFORM.                    " APPEND_FIELDCAT

 

 

*&---------------------------------------------------------------------*

*&      Form  SECOND_PAGE

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

FORM SECOND_PAGE USING R_UCOMM LIKE SY-UCOMM

                                   RS_SELFIELD TYPE SLIS_SELFIELD.

** CHECK WHETHER THE USER CLICKED ON EMP NUMBER OR NOT. IF

** YES DISPALY DETAILED WAGE TYPES INFORMATIN IN SECOND PAGE.

 

  IF RS_SELFIELD-FIELDNAME = 'PERNR'.

 

    LOOP AT IT_PBWLA WHERE PERNR = RS_SELFIELD-VALUE.

      MOVE-CORRESPONDING IT_PBWLA TO IT_PAGE2.

      APPEND IT_PAGE2.

      CLEAR IT_PAGE2.

    ENDLOOP.

 

** PROCESS THE ALV SECOND PAGE.

 

    PERFORM APPEND_FIELDCAT2 USING 'PERNR' 'EMP NO.' ''.

    PERFORM APPEND_FIELDCAT2 USING 'LGART' 'WAGE TYPE' ''.

    PERFORM APPEND_FIELDCAT2 USING 'LGTXT' 'DESCIRPTION' ''.

    PERFORM APPEND_FIELDCAT2 USING 'WAERS' 'CURRENCY' ''.

    PERFORM APPEND_FIELDCAT2 USING 'BETRG' 'AMOUNT' ''.

    PERFORM APPEND_FIELDCAT2 USING 'INDBW' 'IND EVAL' ''.

 

** CALL THE ALV FUNCTION MODULE.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

*        IS_LAYOUT     =

        IT_FIELDCAT   = IT_FIELDCAT2[]

      TABLES

        T_OUTTAB      = IT_PAGE2

      EXCEPTIONS

        PROGRAM_ERROR = 1

        OTHERS        = 2.

    IF SY-SUBRC <> 0.

      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

 

 

  ENDIF.

ENDFORM.                    "SECOND_PAGE

 

 

*&---------------------------------------------------------------------*

*&      Form  APPEND_FIELDCAT2

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_0459   text

*      -->P_0460   text

*      -->P_0461   text

*----------------------------------------------------------------------*

FORM APPEND_FIELDCAT2  USING    VALUE(P_0459)

                                VALUE(P_0460)

                                VALUE(P_0461).

  IT_FIELDCAT2-FIELDNAME = P_0459.

  IT_FIELDCAT2-SELTEXT_L = P_0460.

  APPEND IT_FIELDCAT2.

  CLEAR IT_FIELDCAT2.

 

ENDFORM.                    " APPEND_FIELDCAT2

 

 

Regards,

Mayure.


A simple and sample program to get the internal table data into XML format

$
0
0

Here by I am mentioning a sample report program to download the internal table data into XML file.

 

For converting  the internal table data into XML. We do the following steps

 

1. Create a table type at dictionary level for final internal table in our report program and XML Conversion program.

2. Create internal table referring that dictionary data type.

3. Fetch and fill the data into internal table.

 

4. In XML Transformation (XSLT_TOOL) add that table type as root node and activate the transformation.

 

5. Call that Transformation in our report program and give our internal table as input for that and we will get the XML data as output.

6. Use Function module, SCOL_TRACE_SHOW_XML to display the XML on list output.

7. Use Method , CL_SALV_DATA_SERVICES=>DOWNLOAD_XML_TO_FILE to download the converted XML file as file.

 

 

 

Below is the Screenshot driven flow.

 

1. OPEN Tcode XSLT_TOOL . Give the name and click on create.

  Select Simple transformation and click on Save.

1.JPG

 

2. Click on Edit simple transformation graphically.

2.JPG

 

3. Right Click on Root and select INSERT ROOT NODE. And give a name to root and give the dictionary table type as below.

and drag the newly created root node from left window to right window (simple transformation).

Activate it and exit from it.

 

3.JPG

4.JPG

5.JPG

 

4. Open ABAP Editor and do the following Code to get the data transformed into XML.

*&---------------------------------------------------------------------*

*& Report  ZR_C101_XML_TEST1

*&

*&---------------------------------------------------------------------*

*&    Report program to dispaly & Download the Internal table data into

*& XML file.

*&

*&---------------------------------------------------------------------*

 

REPORT  ZR_C101_XML_TEST1.

 

** Declaration of Internaltable referring to abap dictionary structure.

DATA: IT_MARD TYPE ZTT_MARD WITH HEADER LINE.

 

** Select options for Material number.

SELECT-OPTIONS S_MATNR FOR IT_MARD-MATNR.

 

**Select the file path to download the XML file.

PARAMETERS P_FILE TYPE STRING.

 

DATA PRAVEEN_XML TYPE XSTRING.

** F4 funtionality for file name field.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

 

  CALL METHOD CL_RSAN_UT_FILES=>F4

    EXPORTING

      I_APPLSERV       = SPACE

      I_TITLE          = 'SAVE TO XML'

      I_GUI_EXTENSION  = 'XML'

      I_GUI_EXT_FILTER = 'XML'

    CHANGING

      C_FILE_NAME      = P_FILE

    EXCEPTIONS

      FAILED           = 1

      OTHERS           = 2.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

 

 

START-OF-SELECTION.

** Fetch the data from database to internal table.

  SELECT MATNR

         WERKS

         LGORT

         LFGJA INTO TABLE IT_MARD

               FROM MARD

               WHERE MATNR IN S_MATNR.

******************************************************************************************

** Call the transformation Program name which we created in TCODE XSLT_TOOL.

  CALL TRANSFORMATION ZTR_C101_3

  SOURCE ZROOT = IT_MARD[]

  RESULT XML PRAVEEN_XML.

******************************************************************************************

 

 

** Call function for displaying the XML file on to list output.

  CALL FUNCTION 'SCOL_TRACE_SHOW_XML'

    EXPORTING

      XDOC = PRAVEEN_XML.

******************************************************************

 

 

**************************************************************

* Call the Method to download the XML data as File on the file system.

  CALL METHOD CL_SALV_DATA_SERVICES=>DOWNLOAD_XML_TO_FILE

    EXPORTING

      FILENAME = P_FILE

      XCONTENT = PRAVEEN_XML.

 

**************************************************************

 

 

And in the final the output as below.

 

 

6.JPG

 

 

Thanks & Regards,

Mayure.

Featured Content for ABAP Development

$
0
0

SAP NetWeaver AS Add-On for Code Vulnerability Analysis

http://scn.sap.com/profile-image-display.jspa?imageID=21719&size=72Have you ever heard about the Code Vulnerability Analyzer? This new SAP NetWeaver Add-On allows to search for potential security vulnerabilities in ABAP source code. For more information, read the SAP Insider's article Start Your ABAP Applications on Solid Ground written by Patrick Hildenbrand.February 25, 2014

 

Free Developer Edition: AS ABAP incl. BW on SAP HANA

Do you want to explore the latest features of SAP Business Warehouse, try out ABAP development on SAP HANA or the SAP HANA interactive education? Now we offer a new developer edition of AS ABAP incl. BW 7.4 SP5 on SAP HANA SP7 for our developer community.February 18, 2014

 

ABAP Language News for Release 7.40 SP05

http://scn.sap.com/profile-image-display.jspa?imageID=26426&size=72SP05 for AS ABAP 7.40 comes with a new kernel release 741 and a new kernel release means new ABAP language features. Read this blog by Horst Keller covering the most important ABAP language news.February 6, 2014

 

What is ANST and why aren't you using it?

http://scn.sap.com/profile-image-display.jspa?imageID=10179&size=72Do you already know ANST, the Automated Notes Search Tool? This powerful application searches SAP notes for a specific problem based on the issue in your system. For more information, read this blog by Kristen Scheffler.January 9, 2014

 

ABAP Developement Tools for Eclipse 2.19

The ABAP Development Tools for Eclipse 2.19 are available as of today! Read this interesting blog by Thomas Fiedler to find out what's new and where to get the latest version.December 20, 2013

 

Download PDF copy for any report

$
0
0

Guys,

Sometime, client may ask some tool to be able to download report output (be it classical, ALV grid or list) to PDF. One of customer asked us to enable them to download PDF thereby restricting it’s staff activities.  I have made efforts not to restrict its applicability and maintain generality.

This functionality is encapsulated in a Function module and encompasses following action.

  • Prepare job name.
  • Schedule job in background and read latest spool.
  • Introduce wait period of 120seconds to let the job complete.
  • Download PDF locally with spool number as input upon completion of job.

Steps to be carried out in target report:

  • Prepare selection table.
  • Call function module on click of button ‘PDF Download’ added to toolbar.

There are few things you should keep in mind:

  • Selection criteria should be filled in the selection table as it appears in selection screen.
  • In case of ALV generation using FM ‘REUSE_ALV_GRID_DISPLAY’ do remember to pass parameter ‘SLIS_PRINT_ALV’ to suppress list info like no of records appearing in PDF (ls_print-no_print_listinfos = 'X').
  • An endless loop in a report can result in unexpected result (Including long running job).

 

At bottom I have included an example how to implement in your report.

 

Please provide your suggestion/inputs and like it if it is helpful.

 

Cheers,

N. Gautam

Report for batch job detail extraction with step variant and variant values

$
0
0

This program does the following....

1. Extract data for any job with all details up to variant level including values of variables in the variant.

2. Find a particular job with variant value specified

 

It Provides the lowest level detail for a job and is very useful.

Dynamic selection screen

$
0
0

The purpose of this sample code is to generate select-options dynamically.

The selection-screen takes the table name as input and generates the select-options for the fields selected dynamically.

 

1.Selection screen:

Image1.JPG

 

 

2.Creating dynamic selection screen

Interface to read a table from the ABAP Dictionary

 

for example: iv_kotab = A549
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
NAME
= IV_KOTAB
TABLES
DD03P_TAB
= GT_DD03P.

 

Build dynamic selection:

  •   Build Selections
    S_SELOPT
    -SIGN = 'I'.
    S_SELOPT
    -OPTION = 'EQ'.

 

LOOP AT GT_DD03P.
CASE GT_DD03P-FIELDNAME.
WHEN 'MANDT'
OR 'KAPPL'
OR 'KSCHL'
OR 'KNUMH'.
* Do nothing
WHEN OTHERS.
* Insert other selection
CONCATENATE
GT_DD03P
-TABNAME '-' GT_DD03P-FIELDNAME
INTO S_SELOPT-LOW.
APPEND S_SELOPT.
ENDCASE.
ENDCASE.
ENDLOOP.

 

Looping the seleopt table to generate the selection code

 

CONCATENATE 'SELECT-OPTIONS:' W_PARAMNAME INTO W_SRC
SEPARATED BY SPACE.
CONCATENATE W_SRC 'FOR' W_TABNAME INTO W_SRC
SEPARATED BY SPACE.
CONCATENATE W_SRC '-' W_FIELDNAME '.' INTO W_SRC.

* add field description at offset 42 - if possible
W_STRLEN
= STRLEN( W_SRC ).
IF W_STRLEN < 42.
WRITE: '"' TO W_SRC+42.
WRITE: W_FIELDTEXT TO W_SRC+43.
ELSE.
CONCATENATE W_SRC '"' W_FIELDTEXT INTO W_SRC.
ENDIF.

APPEND_LINE I_SELSCR_SRC W_SRC
.

* generate a text element for this select-option
CLEAR I_TEXTS.
I_TEXTS-
ID = 'S'.
I_TEXTS-
KEY = W_PARAMNAME.
I_TEXTS-ENTRY
= 'D'. "=take DDIC text if available
WRITE: W_FIELDTEXT TO I_TEXTS-ENTRY+8.
APPEND I_TEXTS.

* *****************************************
* Build some Types that reflects the Selection fields.
APPEND_EMPTY I_TYPES_SRC
.
CONCATENATE
'TYPES: BEGIN OF TP_' W_PARAMNAME+2(6) '.' INTO W_SRC.
APPEND_LINE I_TYPES_SRC W_SRC
.

CONCATENATE
'INCLUDE STRUCTURE' W_PARAMNAME '.' INTO W_SRC
SEPARATED BY SPACE.
APPEND_LINE I_TYPES_SRC W_SRC
.

CONCATENATE
'TYPES: END OF TP_' W_PARAMNAME+2(6) '.' INTO W_SRC.
APPEND_LINE I_TYPES_SRC W_SRC
.

 

  •   Combine all statements for selection include

    * Table declaration
    CONCATENATE
    'TABLES:' GV_KOTAB '.'
    INTO W_SRC SEPARATED BY SPACE.
    APPEND W_SRC TO L_SOURCE.

    * Frame start
    W_SRC =
    'SELECTION-SCREEN BEGIN OF BLOCK B0 WITH FRAME.'.
    APPEND W_SRC TO L_SOURCE.

    * Selection options
    APPEND LINES OF I_SELSCR_SRC TO L_SOURCE.

    * Frame end
    W_SRC =
    'SELECTION-SCREEN END OF BLOCK B0.'.
    APPEND W_SRC TO L_SOURCE.

    * Types
    APPEND LINES OF I_TYPES_SRC TO L_SOURCE.
    REFRESH I_TYPES_SRC.

    * ********************************
    * Add report title and change selection texts as text elements
    CLEAR I_TEXTS.
    I_TEXTS
    -ID = 'R'.
    I_TEXTS
    -ENTRY = 'Selection for Conversion of Condition Records'.
    APPEND I_TEXTS.
    SORT I_TEXTS BY ID KEY.

    * Create text elements
    DELETE TEXTPOOL C_DYN_REPID LANGUAGE SY-LANGU.
    INSERT TEXTPOOL C_DYN_REPID FROM I_TEXTS LANGUAGE SY-LANGU.

    * ********************************
    * Rebuild the selection include
    * program code inserted into ABAP repository
    INSERT REPORT C_DYN_REPID_SELECTION FROM L_SOURCE
    KEEPING DIRECTORY ENTRY.

 

Output:

 

Image2.JPG

Viewing all 935 articles
Browse latest View live