Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Dynamically change the selection screen of a report based on the radio buttons.

SAP Radio biutton

Dynamically change the selection screen of a report based on the radio buttons.
Here we have requirement to enable a selection screen (second selection screen) based on radio button RAD2 in first selection screen .Also restricting input to single values using  FM SELECT_OPTIONS_RESTRICT.


Change directory entry or development of any development like program, function module ,forms ,sap scripts etc.
  1. Go to tcode Se03
  2. Click on the change object directory entries next screen will come .Here we can change development class for any sap object like program ,function group, data element etc…For example change dev class of program check the check box as shown below give program name and execute
  3. Double click on the package to get the next screen
  4. Now here click the change button to change the development class shown below Similarly for  forms go to se03 follow the same procedure only change the entries as shown below Enter  ‘FORM’ press enter ,give the form name and check the check box as shown below


Protected by Copyscape Web Copyright Checker

web service for a (RFC)FM


Craete a function module and use it as a web service.

In this example we have created a web service for a  (RFC)FM .

Step 1.Go -->se 37 -->create a (RFC) function module

Import parameter
Export parameter




Code for the function module

DATA :  L_T_0105 TYPE  STANDARD TABLE OF P0105,
          WA_0105  
TYPE  P0105.

  
CALL FUNCTION 'HR_READ_SUBTYPE'
       
EXPORTING
*    TCLAS                 = 'A'
         PERNR                 
PERNR
         INFTY                 
'0105'
         SUBTY                 
'0001'
*    SPRPS                 = '*'
        BEGDA                 
SY-DATUM
        ENDDA                 
SY-DATUM
       
TABLES
         INFTY_TAB            
=  L_T_0105[]
      
EXCEPTIONS
        INFTY_NOT_FOUND       
1
        INVALID_INPUT         
2
        
OTHERS                3
               .
  
IF SY-SUBRC <> 0.


  
ENDIF.
  
SORT L_T_0105 BY ENDDA DESCENDING.
  
READ TABLE L_T_0105 INTO WA_0105 INDEX 1.
  
IF SY-SUBRC 0 .
    
WRITE WA_0105-USRID TO  E_NAME.
    
CLEAR WA_0105.
  
ENDIF.







Save it to local
l

Now go to the tcode soamanager the below screen will appear in web browser
Go to the single service administration


We will get the list of web services now choose zTest_webservice (motioned while creating the web services)

This will open WSDL save as XML



Now go to the click display binding WSDL URL


Example: http://:8000/sap/bc/srt/wsdl/bndg_E13C4BD379AE8AF1BF850026554B371E/wsdl11/
allinone/ws_policy/document?sap-client=011

Go the EP portal and run the web services using above link
Protected by Copyscape Web Copyright Checker

























Variants for report programs






A Report program can be executed in background in two ways:

Method 1:  First create a variant for the report.
                 Then Go to SE38-->Program-->Execute-->Background.
Method 2:  Go to sm36
                  Specify job name and Job class--> Step tab in the application tool bar
                  Specify program name
                  Specify variant
--> Save it-->Save the job-->
                 Will get a message saying ' job has been scheduled'.
                 Go to tcode -->sm37-->check scheduled checkbox-->Execute.


Protected by Copyscape Web Copyright Checker

Create a variant for Transaction code


The Transaction code variant is used to organize the initial Screens of SAP transactions, and is user specific. These types of variants can be used to pre-populate field(s) each and every time that particular transaction is accessed.

Example:
    A variant can be created for any transaction.
    As an example I have chosen IW38 (Change PM Orders) transaction.
  1. In the initial screen of the transaction, populate the search fields that you desire to be pre-populated.
  2. Click on the save button   
  3. Enter the Variant name and Description.
  4. Check the check boxes under ‘Required fields’ column for all the fields that  

            have to be pre-populated.
      Click on the save button     .

  1. Click on the variants button(



Creating a variant using Selection variables
Variants can also be set up to hide field(s), make field as ‘required’  
well as lock in parameters into the fields that should not be changed. Fields that
are dynamic, such as date field, can also be set up so that a certain parameter
defaults or can be pre-populated based on requirement. These types of fields
are known as ‘Selection Variables’.

In this example , a variant will be created such that the ‘Valid From' date will
default to the current date.
  1. Open transaction IH01 (Functional Location structure display).
  2. While saving  select the variant name i.e. CURRENT DATE
  3. Click on the Save button      .




Protected by Copyscape Web Copyright Checker

Create a Layout Variant



A Layout variant can be used to pull in additional information into a list display and organize the information to a User’s specifications. This type of variant is again User specific. Layout variants can be created for any Transaction.

In this example, A Layout variant is created for transaction IW28( Change
Notification).

A Layout variant can be used to pull in additional information into a list display and organize the information to a User’s specifications. This type of variant is again User specific. Layout variants can be created for any Transaction.

In this example, A Layout variant is created for transaction IW28(Change
Notification).
On the initial screen, enter in the desired search criteria.
In this example I am entering the ‘Notification date range’ with ‘notification status’ as Outstanding and Completed.
1.  Click on the execute button      .
         On the initial screen, enter in the desired search criteria.
   In this example I am entering the ‘Notification date range’ with ‘notification
   status’ as Outstanding and Completed.
2.  Click on the execute button.

List of tables to store Variants:

TVARV --> for storing the variants (TVARVC- client specific)VARID --> Variant directoryVARIT --> Variant texts
             
Transaction and screen variants
Transaction variant
  • Transaction variant is a used to create some tailored version of standard SAP transaction without any actual modification i.e a standard transaction can be modified as per the requirement.
  • It can be used to hide fields, menu functions, screens, to supply individual fields with default values or to change the ready for input status of one or more fields.    
Transaction variant can be created in two steps:
      1) Create a Transaction variant in SHD0
      2) Attach the transaction variant to a transaction




Protected by Copyscape Web Copyright Checker

Interactive report example in ABAP


Interactive report example:-

In this example we tried to show how the interactive report works. Here for a storage location, we will get a list of material and will get the creation date and last changes date for material (MATNR) on double click Event AT LINE-SELECTION.


tables :mard.
DATA : wa_mard TYPE mard,
       it_mard TYPE  STANDARD TABLE OF mard.

DATA : wa_mara TYPE mara,
       it_mara TYPE STANDARD TABLE OF mara.

PARAMETERS LGORT TYPE mard-LGORT.

SELECT *
FROM mard
INTO TABLE  it_mard
WHERE LGORT eq LGORT.

LOOP AT it_mard INTO wa_mard.
  WRITE : /1 wa_mard-matnr ,
           20 wa_mard-WERKS color 4,
           40 wa_mard-PSTAT color 5.
  HIDE wa_mard-matnr. "-*Here the contents of the line selected will be stored
ENDLOOP.

AT LINE-SELECTION.
  ULINE.
  IF sy-lsind = 1.
    WRITE :  /1 'MATERIAL NO'color 1,
             20 'Created On',
             40 'Date of Last Change'color 2.
    ULINE.
  ENDIF.
SELECT *
FROM mara
INTO TABLE it_mara  "
WHERE matnr = wa_mard-matnr. "contents of the line from above
  LOOP AT it_mara INTO wa_mara.
    WRITE :  /1 wa_mara-matnr color 1,
             20 wa_mara-ERSDA ,
             40 wa_mara-LAEDA color 2.

  ENDLOOP.
TOP-OF-PAGE.
  WRITE : /1 'MATERIAL NO' ,
         20  'Maintenance status'color 4,
         40  'Created On'color 5.
  ULINE .

Execute the report

Click execute
output

Click on the 271 (material number)
Debug view

Now we got the creation and last changes date


Protected by Copyscape Web Copyright Checker

Variant


A Variant is a set of input fields for selection screen. When the program with the same set of input fields run multiple times its useful to save a variant for those fields.
Variants are an interface between the user and the selection screen. Variants can be created in Dialog mode and in background mode.
This not only saves time but avoid some manual mistakes while entering input.

  • Create a Variant for a Report program
    • Execute the Report Program which takes you to the selection screen.
    • Enter the appropriate values in the selection screen fields and click on the save icon.
    • Enter the Variant name and meaning full description.
    • The meaning and use of various options in the variant.  



  1. If you select the field Background only, the variant can only be executed in the background. Otherwise, it can be run both in the background and online.
  2. If you select the field Protect variant, the variant can only be changed by the person who created it or last changed it. 
  3. If you select the field Do not display variant, the variant name appears in the directory, but not in the general input help.
  4. If you flag a field as 'Protected', the relevant selection criterion is protected against changes at runtime, i.e. when you start the program with variant
  5. However, in variant maintenance itself, the field is ready for input.
  6. Hide Field will allow the user to hide fields so that they do not appear on the search criteria screen.
  7.  Save field without values will make the field required ,but will not save data entered in the field.
  8. Required field: to make the fields mandatory.
Variants for report programs

A Report program can be executed in background in two ways:
Method 1:  First create a variant for the report.
                 Then Go to SE38-->Program-->Execute-->Background.
Method 2:  Go to sm36
                  Specify job name and Job class--> Step tab in the application tool bar
                  Specify program name
                  Specify variant
Save it-->Save the job-->
                 Will get a message  ' job has been scheduled'.
                 Go to tcode --->sm37--> check scheduled checkbox-->Execute.

Protected by Copyscape Web Copyright Checker