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

User Guide for SAP NetWeaver AS ABAP 7.4 SP2 on SAP MaxDB [Trial]

$
0
0

This guide describes how to set up your local environment for the SAP NetWeaver AS ABAP 7.4 SP2 on SAP MaxDB trial provided as virtual appliances by the SAP Cloud Appliance Library.

View this Document


SAP Archiving Activity - Part1

$
0
0

Topic: SAP Archiving Activity

Applies to: All the objects (Which holds Transactional Data) in SAP

Steps: Basically, The Process contains 2 steps.

  1. Configuration (Tcode – SARA)
  2. Archiving, Deletion and post processing (TCODE – SARA)

 

Please follow the sequence.

 

Step 1: Configuration (TCODE – SARA)

 

Arc_img1.jpg

I have considered the FI_DOCUMENT object for archiving. (But many objects exists like this)

The transactional data under FI_DOCUMENT object will be archived.

When we press F4 on the selection screen, Below screen would appear and shows all the objects!

Arc_img2.jpg

Click on small_img1.jpgbutton in the initial archiving screen.(in below screen)

Arc_img3.jpg

Click on “Cross-Client File Names/Paths

Arc_img4.jpg

It redirects to the below screen.

Arc_img5.jpg

Select the suitable/similar object for configuration modifications and select copy as (small_img2.jpg ) button.

 

 

Arc_img6.jpg

Since we are doing the Archiving activity for company code T1 (Test 1), we have to change the logical file name accordingly. (Naming convention depends on the organization).

Arc_img7.jpg

Press Enter,

Arc_img8.jpg

Here, please select ‘copy all’ push button.

Arc_img9.jpg

Then again, Press Enter.

Arc_img10.jpg

Save it. (It asks for TR then provides the appropriate TR and saves).

small_img3.jpg

Then, Select the “Logical file name definition, cross-client” and select same logical file name which we have done in earlier step.

Arc_img11.jpg

Select again small_img2.jpg button.

Arc_img12.jpg

Here, replace T1. Since, we are performing the Archiving activity for T1 Company code.

Arc_img13.jpg

Press Enter.

Arc_img14.jpg

Save small_img4.jpg.

small_img3.jpg

Select ‘Assignment of physical paths to logical path’.

Arc_img15.jpg

Enter the Logical File path name which we have created.

Arc_img16.jpg

Press Enter.

Arc_img17.jpg

Go to Initial Screen of the customization again. (SARA)

Arc_img18.jpg

Execute ‘Technical Settings’ as shown above.

Arc_img19.jpg

Please change the logical file with respect to T1 company code.

Arc_img20.jpg

Save It.

Here it prompts for TR. Provide the correct TR and save the settings.

small_img3.jpg

Configuration step (i.e. step 1) completed with the above steps. ..

 

SAP Archiving Activity - Part2 (i.e. Step 2) will be continued.. .

 

Regards

Kiran N

Transfer Data from .NET to SAP using SAP Dot NET connector 3.0

$
0
0

Hi All,

 

This document defines the procedure of transferring data from c#.net programming to sap backend database tables. It needs to install two components on the client PC on which want to transfer data from .NET  to SAP.

       1. Dot NET framework 4.0

       2. SAP Dot NET connector 3.0 - SAP .NET Connector 3.0 is the current version of SAP's development environment for communication between the Microsoft .NET platform and SAP systems. This connector supports RFCs and Web services. It allows you to write different applications such as Web form, Windows form, or console applications in the Microsoft Visual Studio.Net. With the SAP .NET Connector, you can use all common programming languages, such as Visual Basic. NET, C#, or Managed C++. Write .NET Windows and Web form applications that have access to SAP business objects (BAPIs).

         .NET connector 3.0 is available on SAP market place.

 

Procedure to make BAPI and object type on SAP side:

 

       1. First make a structure for bapi, structure name should start with Z OR Y following by BAPI .  e.x. YBAPI_ATND_RAW

 

        2. Now make a module function which is RFC enabled. So, go to SE37 tcode and give the name as Z OR Y following by BAPI  like ZBAPI_ATTENDANCE_PUNCH_DATA and in attributes tick on Remote-Enabled Module and tick on Start immed as shown below:

 

Untitled.png

       3. Must define the export parameter return type bapireturn.


Untitled.png

        4. Define the parameter name in tables as shown below:

 

Untitled.png

 

             5. Write the source code:


*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     VALUE(RETURN) TYPE  BAPIRETURN
*"  TABLES
*"      ITAB STRUCTURE  YBAPI_ATND_RAW
*"----------------------------------------------------------------------
TABLES : yatnrcraw.

DATA : v_srno(5) TYPE n,
wa_itab3
LIKELINEOF itab.

DATA : BEGINOF itab4 OCCURS0.
INCLUDESTRUCTURE yatnrcraw.
DATA : ENDOF itab4.

CLEAR v_srno.
LOOPAT itab INTO wa_itab3.
v_srno = v_srno +
1.
CONDENSE wa_itab3-tmp.
*    CONCATENATE wa_itab3-tmp+24(2) '.' wa_itab3-tmp+22(2) '.' wa_itab3-tmp+18(4) INTO yatndent-pchdt.
yatnrcraw-ardata = wa_itab3-tmp.

CONCATENATE wa_itab3-tmp+18(4)
wa_itab3-tmp+
22(2)
wa_itab3-tmp+
24(2INTO yatnrcraw-pchdt.

CONCATENATE wa_itab3-tmp+26(2)
wa_itab3-tmp+
28(2) '00'INTO yatnrcraw-time.

yatnrcraw-mcno = wa_itab3-tmp+
31(7).
yatnrcraw-empcd = wa_itab3-tmp+
12(6).

WRITE wa_itab3-tmp+30(1) TO yatnrcraw-ioind.


CALLFUNCTION'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input  = yatnrcraw-empcd
IMPORTING
output = yatnrcraw-empcd.

yatnrcraw-upddt  = sy-datum.
yatnrcraw-uname  = sy-uname.


**    INSERT yatnrcraw FROM yatnrcraw.
INSERT yatnrcraw INTOTABLE itab4.
CLEAR yatnrcraw.
ENDLOOP.

IF itab4[] ISNOTINITIAL.
SORT itab4 BY pchdt empcd time.
DELETEADJACENTDUPLICATESFROM itab4 COMPARING pchdt empcd time.

LOOPAT itab4.
SELECT *
FROM yatnrcraw
WHERE ardata = itab4-ardata.
ENDSELECT.

IF sy-subrc EQ0.
CLEAR itab4.
CONTINUE.
ENDIF.

INSERT yatnrcraw FROM itab4.
CLEAR itab4.
ENDLOOP.

ENDIF.

*  IF v_srno GT 0.
*    MESSAGE 'Data has successfully uploaded' TYPE 'I'.
*  ENDIF.

Activate the module.

NOTE: above code is just an example, define the tables, import and export parameters as per your requirement and develop the logic as per your requirement. Must define the RETURN parameter in export.

 

       6. Create the API Method Using the BAPI WIZARD: Develop the object type using the Business Object builder tcode SWO1. Ex. Give the name ZATND

 

Untitled.png

 

       7 . The next step is to add the ZBAPI_ATTENDANCE_PUNCH_DATA method to the business object. Select Utilities -> API methods -> Add method and write the name of the function module in the dialog box. Next the dialog ox show below will be shown. This is the start screen of the BAPI wizard

 

Untitled.png

 

     Then click on OK then get the below screen.


Untitled.png

 

Then click on next button get the below screen, which defines all the import, export parameters. Here in method parameter and name comes by default as same as name in function module. If requires change teh parameter name in object type.

 

Untitled.png

 

Get a screen and click on OK.

After finished the wizard, notice that the  ZbapiPunchData method has been added to the business object.

 

Untitled.png

 

Double-click on the method to see its properties. To use the business object you must change the Object type status to Implemented. Use menu Edit->Change releases status->Object type->To implemented. No you can test the object (Press F8).

Note that the BAPI wizard has added a wrapper class for the function module so it can be ued as method in the business object. Choose menu Goto->Program to display the program:

***** Implementation of object type ZATND1               *****

INCLUDE <OBJECT>.

BEGIN_DATA OBJECT. " Do not change.. DATA is generated

* only private members may be inserted into structure private

DATA:

" begin of private,

" to declare private attributes remove comments and

" insert private attributes here ...

" end of private,

KEY LIKE SWOTOBJID-OBJKEY.

END_DATA OBJECT. " Do not change.. DATA is generated

 

BEGIN_METHOD ZBAPIPUNCHDATA CHANGING CONTAINER.

DATA:

RETURN LIKE BAPIRETURN,

ITAB LIKE YBAPI_ATND_RAW OCCURS 0.

SWC_GET_TABLE CONTAINER 'Itab' ITAB.

  CALL FUNCTION 'ZBAPI_ATTENDANCE_PUNCH_DATA'

IMPORTING

RETURN = RETURN

TABLES

ITAB = ITAB

EXCEPTIONS

OTHERS = 01.

  CASE SY-SUBRC.

    WHEN 0.            " OK

    WHEN OTHERS.       " to be implemented

ENDCASE.

SWC_SET_ELEMENT CONTAINER 'Return' RETURN.

SWC_SET_TABLE CONTAINER 'Itab' ITAB.

END_METHOD.

Now click on this to generate the object and get back to initial screen. Follow the path Object Type -> Change Release Status to -> Released.

Release the BAPI as a method in the BOR (Release the methods you has created - Set the cursor on the method then
Edit -> Change release status -> Object type component -> To released)


Procedure to develop code in Microsoft Visual C#. NET:

 

       1. Develop a new project named as DataToSap and go to the form open the code

Untitled.png

 

         2.      Open the solution manager and right click on References and add reference. Go to the BROWSE tab and add the components from the location as path shown below:

 

C:\Program Files\SAP\SAP_DotNetConnector3_x86

 

And the components as shown below:

 

Untitled.png

 

 

Click on OK, now both the components are added.

 

Untitled.png

 

3. Add the namespance using SAP.Middleware.Connector;

And copy the following code...

 

  publicpartialclassForm1 : Form

    {

        public Form1()

        {

InitializeComponent();

SetupUI();

        }

 

        privatevoid SetupUI()

        {

 

            try

            {

WriteToFile();

            }

            catch (Exception)

            {

           

System.Environment.Exit(0);

            }

 

        }

 

        privatevoid WriteToFile()

        {

 

 

            try

            {

RfcConfigParameters rfc = new RfcConfigParameters();

rfc.Add(RfcConfigParameters.Name, "mySapName");

rfc.Add(RfcConfigParameters.AppServerHost, "10.147.1.3");

rfc.Add(RfcConfigParameters.Client, "410");

rfc.Add(RfcConfigParameters.User, "JSTIT");

rfc.Add(RfcConfigParameters.Password, "unitech@1");

rfc.Add(RfcConfigParameters.SystemNumber, "00");

rfc.Add(RfcConfigParameters.Language, "EN");

rfc.Add(RfcConfigParameters.PoolSize, "5");

rfc.Add(RfcConfigParameters.PeakConnectionsLimit, "10");

rfc.Add(RfcConfigParameters.ConnectionIdleTimeout, "500");

 

RfcDestination rfcDest = RfcDestinationManager.GetDestination(rfc);

RfcRepository rfcRep = rfcDest.Repository;

IRfcFunction function = rfcRep.CreateFunction("ZBAPI_ATTENDANCE_PUNCH_DATA");

IRfcTable table = function.GetTable("Itab");

 

 

 

table.Insert();

table.SetValue("TMP", "00001100000010057 20130918933I0000101");

function.Invoke(rfcDest);

table.Insert();

table.SetValue("TMP", "00001100000010057 20130919933I0000101");

 

 

function.Invoke(rfcDest);

 

 

            }

            catch (Exception e)

            {

MessageBox.Show(e.Message.ToString());

            }

 

 

        }

 

    }

 

       4. Also copy all the dll files of .net connector folder which is in SAP folder in program files of C drive and paste in the bin folder of the .net project.

 

NOTE: 1. above program is just an example for getting only knowledge on this.

               2. Also need some knowledge on C#.NET.

 

Many Thanks / Himanshu Gupta


SAP Archiving Activity - Part2

$
0
0

After SAP Archiving Activity - Part1, Please proceed with below sequence for Step 2 completion..

 

Archiving, Deletion and post processing activities need to be performed using TCODE SARA.

Arc_img1.jpg

Select the highlighted Archive push button.

Arc_img2.jpg

Arc_img3.jpg

Select the ‘Maintain’ Push button.

Enter the appropriate company codes and also year and periods.

Arc_img4.jpg

Then, Press Enter.

Arc_img5.jpg

Now variant has been created as per the selection parameters.

small_img1.jpg

Press F3 till the below screen appears.

Arc_img6.jpg

Select ‘Start date’.

Arc_img7.jpg

In above screen,

  • Select ‘Immediate’ Push button
    • Select ‘Check’ Push button
      • Finally ‘Save’ it.

Arc_img8.jpg

Then, select the ‘Spool params’ push button in the screen.

Arc_img9.jpg

Provide the Output device= LOCL

 

Unmark ‘Print Immediately’ and ‘delete after output’. Then, Press Enter.

Arc_img10.jpg

Again, Press Enter.

Arc_img11.jpg

Here, observe the rectangle box. “Both must be in Green and Maintained”.

Press small_img2.jpg (Execute).

Arc_img12.jpg

As per the above screenshot we can notice that new archiving job has been generated. To View the job, please press small_img3.jpg  button.

Arc_img13.jpg

Job is in Active status. After the successful completion of the job, Deletion activity starts.

Arc_img14.jpg

Press Go back (For Deletion Activity=> Click on Delete button )

Arc_img15.jpg

Arc_img16.jpg

Press the ‘Archive selection’ push button.

Arc_img17.jpg

Select all the files for deletion and press enter.

Arc_img18.jpg

Arc_img19.jpg

In above screen,

  • Select ‘Immediate’ Push button
    • Select ‘Check’ Push button
      • Finally ‘Save’ it.

Arc_img20.jpg

Arc_img21.jpg

After above selection parameters have been filled, Press Enter.

Arc_img22.jpg

Here, observe the rectangle box. “All must be in Green and Maintained”.

  Then, Press small_img2.jpg Execute

Arc_img23.jpg

Arc_img24.jpg

Here we can notice the ‘Active’ Status jobs. Wait for 'Finished' status.

Arc_img25.jpg

After jobs finished successfully, The Post processing activity needs to be initiated in the following way!

Until this part, Deletion activity has been finished.

 

Post Processing:

TCODE: SARA

Arc_img26.jpg

Press the ‘Postpr.’ Button as shown above

Arc_img27.jpg

Arc_img28.jpg

Save,

Arc_img29.jpg

Press Enter

Arc_img30.jpg

 

Go Back to the below screen..

Arc_img31.jpg

Maintain Start date and Spool params as mentioned earlier.

Arc_img32.jpg

Then, Execute (small_img2.jpg)

Arc_img33.jpg

Once the active job finished successfully, we can understand that post processing step also completed.

 

This is the SAP Archiving activity Process...

 

Cheers...

 

Regards

Kiran N


 

 

 

 

 


Creation of RESTful Webservice in SAP

$
0
0

As you all aware of that creation of SOA (System oriented architecture) web service using FM. Now let's create a REST(Representational state transfer) web service which is getting much attention now a days.

 

Recently I have been given with a requirement to create a REST( Representational state transfer) web service which returns the sales order details in XML format.

 

Business requirement: Consumer want to get the details of sales order from the SAP by passing the sales order number as ID through URL.

 

What is REST ful web service?

It's a named resource which can be accessed using the URL containing the ID (In our case Sales order number ) of the resource in distributed environment.

 

Eg: http://eccehp4.myserver.com:8000/sap/bc/zrest_service/0000004969

 

With the help of SCN and Wiki documents I have created Web service as below.

 

Step1: Create a handler class which is having the business logic to get the sales order details

           Go to se24 enter the class name

 

 

Step 2: Now we need to implement the interface IF_HTTP_EXTENSION


 

You can see the method HANDLE_REQUEST from the interface IF_HTTP_EXTENSION.We will use this method in future to implement business logic.

 

 

Step 3:Write below code in the HANDLE_REQUEST method

 


 

Source code:

method IF_HTTP_EXTENSION~HANDLE_REQUEST.

 

  data:lv_path type string,

       lv_data type string,

       lt_data type table of string.

 

  types:begin of ty_head,

        VBELN type vbak-VBELN,

        KUNNR type vbak-KUNNR,

        VKORG type vbak-VKORG,

        end of ty_head.

 

  data:ls_head type ty_head,

       lt_list type table of BAPIORDERS,

       ls_list type BAPIORDERS,

       XML_OUT type string.

 

* get the request attributes

  lv_path = server->REQUEST->get_header_field( name = '~PATH_INFO' ).

 

  SHIFT lv_path LEFT BY 1 PLACES.

 

* Get the sales order details

 

  select single vbeln

                kunnr

                vkorg

           into ls_head

           from vbak

          where vbeln = lv_path.

 

* Convert the data to  XML format

 

  CALL TRANSFORMATION ID

               SOURCE TAB = ls_head

           RESULT XML XML_OUT

              OPTIONS XML_HEADER = 'WITHOUT_ENCODING'.

 

* Set the converted data to Browser

  server->response->set_cdata( data = XML_OUT ).

 

endmethod.

 

Step4: Go to transaction SICF and click on Execute button

 


 

Step 5: Create a child node under the services hierarchy by right click on the node. I have created services in the following path

 

Default host->SAP->bc

 

Step 6: Enter the service name click to continue

 


 

Added service will be under the respective hierarchy as below

 

 

Step 7: Double click on the service zrest_service then below screen will appear


 

Step 8: Go to Handler list tab and give the handler name which we created earlier as ZCL_SALES_ORDER_HANDLER

Step 9: Save and activate the service as below

 


 

Step 10: Now test the service

 


 

Step 11:Give sales order number in URL and click F5


Note: To debugthe web service you have to put external break point in the method HANDLE_REQUEST

 

Reference Link :  Building Mash-Ups and simplifying Application Integration withRESTful Web Services in SAP ABAP

Understanding Debugging Techniques in SAP ABAP

$
0
0
OBJECTIVE:
This document will give an overview about the debugging apporach in SAP ABAP.
Introduction:

ABAP Debugger:

  • An integrated test tool within the ABAP workbench
  • Used  to check program logic and find errors in the source code of an ABAP program
  • Here a running program is interrupted after every step, allowing you to check its processing logic and the results of individual statements
  • Provides an efficient means of identifying errors in ABAP programs.

Starting the Debugger:

    • Two possible ways for starting the Debugger in the ABAP Workbench

 

      • Debugging without Breakpoint
      • Debugging with Breakpoint

Debugging without Breakpoint

     You can start the Debugger as follows:
  • In SE80: Select a program or transaction and from the top menu choose Program® Test ® Debugging.
  • In SE38: From the top menu choose Program®Execute®Debugging.
  • From any other screen: From the top menu choose System®Utilities®Debug ABAP
          Or Enter/h in the command field and press enter

Debugging with Breakpoints

  • A breakpoint is a signal in a specific line of the program source code.
  • This signal indicates to the ABAP runtime processor to stop the program at the relevant line and start the ABAP Debugger.
Different ways to put break points:

 

 

1. Hard coded / Static break points

2. Dynamic break points

 

 

1. Hard coded / Static break points:

 

You can put a breakpoint in our program by writing statement “BREAK-POINT” or “BREAK <userid>”.

 

Use “BREAK <userid>” to stop the program execution when a specific user is executing the program.

 

NOTE:

 

Static breakpoints are not normally user-specific. Once a user has inserted the statement BREAK-POINT or BREAK name in an ABAP program, the system always interrupts the program at that point for that user or only for the user name. This procedure is only useful in the development phase of an application, when the program execution is always to be interrupted at the same place.

 

 

 

2. Dynamic break points:

 

 

  • We can put dynamic breakpoints from SE80 or SE38.
  • These are always user-specific.
  • Are deleted when we log off R/3 system.
  • More flexible than static breakpoints because you can delete/deactivate them at runtime.

 

 

Keys used in Debugging:

 

  • F5 (Single Step):  Use this key  to go line by line throughout the program.

 

  • F6 (Execute):  This is mainly used to execute a Function Module in a single step; without entering into the Function Module / Subroutine.

 

  • F7  (Return):  The Debugger returns to the point at which control returns to the main program. We use this option to return from other programs or to return from a module or subroutine or a function module.

 

  • F8 (Run / continue):  Use this option to process the program up to the next breakpoint. If there are no more breakpoints in the program, the system exits debugging mode and executes the rest of the program normally.

 

 

I hope above information will be helpful.Your comments and suggestions are most welcome.

 

Rgrds,

Jitendra

 

 

 

 

SAP Shortcut for Webdynpro applications and how to send a mail with sap short cut attachment !

$
0
0

INTRODUCTION

Emails are one of the common methods of notifying users about various changes performed in the system. But when the user needs to view/process the data he/she needs to manually login to the system through the required transactions to access the data. SAP shortcuts come handy in these situations enabling the users to login to the required transactions or custom Webdynpro application directly.

Using SAP shortcuts through email will benefit the users in the following ways:

  • Delivered to a single inbox, hence user does not have to keep checking the UWL/SBWP or other inboxes
  • User does not need to remember the different transactions that he/she needs to work on.


    Detailed Requirements / Technical Description

Consider a scenario when service entry sheet is created in other system like SUS. Now once the SES receives in ERP a notification email is sent to the responsible agent for approval process. In a normal scenario the agent needs to log into the system manually and enter the required transaction. Then the required details need to be entered for approval.

This process can be simplified by sending a shortcut which will navigate the user to the required transaction or custom Webdynpro application. The sample code for this process is given below

Steps to follow:-

1.    Created a Webdynpro application “Z_SES_SHORTCUT_APPROVE” as below, where agent can see the details of the service entry sheet        and decides to approve or reject.

2.    For the above application we create the transaction code “Z_SES_APPROVAL”.

      

         1.png

3.    The sample code for this requirement is given below and the FM can be used in triggering point where SES receives in ERP. (Example          in proxy class in XI interface etc)


  FUNCTION Z_SEND_SHORTCUT_LINK_BY_MAIL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(USER) TYPE  UNAME
*"     REFERENCE(SUBJECT) TYPE  ANY
*"     REFERENCE(TEXTNAME) TYPE  TEXTNAME
*"     REFERENCE(IS_ESSR) TYPE  ESSR
*"     REFERENCE(SHORTCUT_TCODE) TYPE  TCODE
*"     REFERENCE(LINK_WD_APPL) TYPE  ANY
*"  TABLES
*"      ET_RETURN TYPE  BAPIRETURN1_TABTYPE
*"----------------------------------------------------------------------

  DATA lv_appl_link          TYPE string.
DATA send_request          TYPE REF TO cl_bcs.
DATA document              TYPE REF TO cl_document_bcs
DATA bcs_exception         TYPE REF TO cx_bcs.
DATA lv_subject_attach     TYPE so_obj_des.
DATA lv_len_obj TYPE  so_obj_len.
DATA lv_langu TYPE sy-langu.
DATA main_text             TYPE bcsy_text.

  DATA sent_to_all           TYPE os_boolean.
DATA lv_text               TYPE string.

  DATA lv_text1              TYPE string.
DATA lv_text2              TYPE string.
DATA lv_string             TYPE string.
DATA lv_url                TYPE string.
  DATA lt_shortcut           TYPE soli_tab.

  DATArecipient             TYPE REF TO  if_recipient_bcs.

  DATAlv_type               TYPEso_obj_tp.

  DATAwa_return          TYPEbapireturn1.                                                                      


IF link_wd_appl IS NOT INITIAL.
lv_type =
'HTM'.
lv_text1 = 'You have been indendified as responsible agent for Service entry sheet no'.
lv_text2 =
'Please approve it'.
CONCATENATE lv_text1 IS_ESSR-lblni lv_text2 INTO lv_text separated by space.

cl_wd_utilities=>construct_wd_url(EXPORTINGapplication_name = lv_appl_link
IMPORTING out_absolute_url = lv_url ).
lv_string =
'Start'.
CONCATENATE lv_text
`<p><a href="`
lv_url
`" target="_top"><b>`
lv_string
'</b></a>'
INTO lv_text.

main_text = cl_document_bcs=>string_to_soli( lv_text ).

ELSEIF shortcut_tcode IS NOT INITIAL.
lv_type =
'RAW'.
lv_text =
'You have been indendified as responsible agent for SES please approve it'.
main_text = cl_document_bcs=>string_to_soli( lv_text ).

   ENDIF.


*     create persistent send request
  TRY.
send_request = cl_bcs=>create_persistent( ).
CATCH cx_send_req_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
ENDTRY.

*  create and set document with attachment
  TRY.
document = cl_document_bcs=>create_document(
i_type    = lv_type
i_text    = main_text
i_subject = lv_subject ).
CATCH cx_document_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
ENDTRY.


IF shortcut_tcode IS NOT INITIAL.
  CONCATENATE '/n*' shortcut_tcode INTO lv_command.

* Create the shortcut as table
CALL FUNCTION 'SWN_CREATE_SHORTCUT'
EXPORTING
i_transaction           = shortcut_tcode
*        i_system_command        = lv_command
i_saplogon_id           = space
*       i_sysid                 = space
i_user                  = user
i_language              = lv_langu
i_windowsize            =
'Normal window'          
IMPORTING
shortcut_table          = lt_shortcut
EXCEPTIONS
inconsistent_parameters =
1                        
OTHERS                  = 2.                       

    TRY.
lv_len_obj = lines( lt_shortcut ) *
255.
CATCH cx_sy_arithmetic_overflow cx_sy_conversion_overflow.
ENDTRY.

lv_subject_attach =
'Personal worklist'.
*     create and set document with attachment
    TRY.
document->add_attachment(
i_attachment_type    =
'SAP'                    
i_attachment_subject = lv_subject_attach
i_attachment_size    = lv_len_obj
i_att_content_text = lt_shortcut ).
CATCH cx_document_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
    ENDTRY.

ENDIF.
*     add document object to send request
    TRY.
send_request->set_document( document ).
CATCH cx_send_req_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
    ENDTRY.

*     create recipient object &  add recipient (e-mail address)

TRY.
recipient ?= cl_sapuser_bcs=>create( user ).

CATCH cx_address_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
ENDTRY.

*     add recipient object to send request
    TRY.
send_request->add_recipient( recipient ).

CATCH cx_send_req_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
ENDTRY.

*        send document ---------------------------------------
    TRY.
sent_to_all = send_request->send( i_with_error_screen = space ).
CATCH cx_bcs INTO bcs_exception.
CLEAR wa_return.
wa_return-type =
'E'.
wa_return-message = bcs_exception->get_longtext( ).
IF wa_return-message IS INITIAL.
wa_return-message = bcs_exception->get_text( ).
ENDIF.
APPEND wa_return TO et_return.
MESSAGE i865(so) WITH bcs_exception->error_type.
ROLLBACK WORK.
EXIT.
ENDTRY.

COMMIT WORK.

   ENDFUNCTION.


4. When the FM is executed  with the following parameters, agent can directly navigated to the required transaction or custom Webdynpro     application from his inbox .

 

2.png3.pngOptional that we can either give SHORTCUT_TCODE i.e. Transaction code or LINK_WD_APPL i.e. Webdynpro application name

 

 

4.png

When we click on Personal worklist it will get navigated to the required transaction or custom Webdynpro application.

 

5.png

6.png

 

 

5. Note:

When the user double clicks on the attachment the pop up window for entering the password is opened as shown below,

 

7.png

Once the user enters the password and clicks on "Log on" the required transaction is opened up directly as shown below.

 

               The system on which the shortcut is executed should have SAP GUI installed and have the target system configured in the SAP                logon pad. If the configuration is not already available then on launching the shortcut the system asks for the logon details as                  shown below,

10.jpg

11.png

 

 

        1.3       SUMMARY

  

         This document provides the following details:
          - Defines how to create a SAP short cut.
                      - Describes how to send a mail with SAP short cut attachment  .

                    

 

 

 

 

 

Thanks and regards,

Praveen Srivastava

Drawing Graphical Charts with ABAP.

$
0
0

Many times a graphical chart output is required by the clients since a graph is much more appealing to the user and enables a better analysis of data. Some achieve this by exporting it to Excel and using the graph feature of Microsoft Excel. It is however quite simple to provide the functionality for building graphical charts in your ABAP report itself.

 

Including this feature in your ABAP report is an absolutely productive task since it could take your program to a much more professional level with relatively very little effort required from your side.

 

There are mainly two function modules that are being used to achieve this.

  • Ø GFW_PRES_SHOW
  • Ø GRAPH_MATRIX_3D

 

There is also a class called CL_GFW whose methods are dedicated to drawing graphs. However, most of the basic graph requirements can be achieved using the above function modules.

 

GFW_PRES_SHOW

 

Suppose you want to draw a line chart showing the revenue from a department over a few years.

 

These are the values for drawing the chart.

 

Year

Revenue

2009

5000

2010

8000

2011

3000

2012

10000

 

The output that you require would be :

 

To achieve this in ABAP

 

Pre-requisite : Create a custom screen say 100 and insert a custom control in it. Give it the name say ‘CONTAINER’

The graph can be easily drawn using the function GFW_PRES_SHOW.

 

   CALLFUNCTION'GFW_PRES_SHOW'
EXPORTING
*                     CONTAINER               =
*                     TOP                     =
*                     LEFT                    =
*                     HEIGHT                  =
*                     WIDTH                   =
PRESENTATION_TYPE       =
*                     HEADER                  =
*                     ORIENTATION             = 1
*                     PARENT                  =
*                     X_AXIS_TITLE            =
*                     Y_AXIS_TITLE            =
*                     FORMAT                  =
*                   IMPORTING
*                     RETVAL                  =
*                     CONTENT_TYPE            =
*                     CONTENT_LENGTH          =
TABLES
VALUES                  =
COLUMN_TEXTS            =
*                     ROW_LABELS              =
*                     COLUMN_LABELS           =
*                     CONTENT                 =
*                  EXCEPTIONS
*                     ERROR_OCCURRED          = 1
*                     OTHERS                  = 2
.

 

The parameter presentation type determines the type of graph that needs to be drawn using the table. Given below are the values of the parameter presentation type corresponding to the different kinds of graphs.

  1. Line charts  - gfw_prestype_lines
  2. Area Chart -  gfw_prestype_area
  3. Horizontal bar chart - gfw_prestype_horizontal_bars
  4. Vertical bar chart  - gfw_prestype_vertical_bars
  5. Pie chart  - gfw_prestype_pie_chart
  6. Time axis chart. - gfw_prestype_time_axis

 

 

The important concept that needs to be understood while using this function module is the logic behind populating the input tables of the function module. Once you understand that, you can easily draw any kind of chart according to the requirement.

 

The two tables parameters values and column_texts are our messengers here.

 

If we consider the above example, column_texts contains the points along the x-axis. That is 2009, 2010, 2011.

 

The structure of the table column_texts is GPRTXT which contains just a single field COLTXT.

 

Append all the x-axis points into this table.

DATA :  X_TEXTS        TYPETABLEOF GPRTXT WITHHEADERLINE.

 

X_TEXTS-COLTXT = '2009'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2010'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2011'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2012'.
APPEND X_TEXTS.

 

The y-axis values corresponding to all x-axis co-ordinates is appended together as a single row in the table VALUES.

Values is a table of structure GPRVAL, which contains the field name for that graph and the values corresponding to the different x-co-ordinates.

 

ROWTXT        GFWXVAL     CHAR 40        0          GFW: First dimension (X value)

VAL1  GFWYVAL     FLTP   16        16        GFW: Second dimension (Y value)

VAL2  GFWYVAL     FLTP   16        16        GFW: Second dimension (Y value)

VAL3  GFWYVAL     FLTP   16        16        GFW: Second dimension (Y value)

VAL4  GFWYVAL     FLTP   16        16        GFW: Second dimension (Y value)

VAL5  GFWYVAL     FLTP   16        16        GFW: Second dimension (Y value)

 

You can enter up to 32 values, ie, upto 32 points on the x co-ordinate is allowed in the Texts table , the y value for each being provided in the Values table.

 

REPORT  ZGRAPHICS.

 

TYPE-POOLS: GFW.

DATA: Y_VALUES       TYPETABLEOF GPRVAL WITHHEADERLINE,
X_TEXTS       
TYPETABLEOF GPRTXT WITHHEADERLINE.
data Ok_code like sy-ucomm.

REFRESH Y_VALUES.
REFRESH X_TEXTS.

Y_VALUES-ROWTXT =
'Sales'.
Y_VALUES-VAL1 =
5000.
Y_VALUES-VAL2 =
8000.
Y_VALUES-VAL3 =
3000.
Y_VALUES-VAL4 =
10000.
APPEND Y_VALUES.

X_TEXTS-COLTXT =
'2009'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2010'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2011'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2012'.
APPEND X_TEXTS.


callscreen100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'PF_100'.
SETTITLEBAR'GRAPHICS'.
*
CALLFUNCTION'GFW_PRES_SHOW'
EXPORTING
CONTAINER         =
'CONTAINER'    "A screen with an empty container must be defined
PRESENTATION_TYPE = GFW_PRESTYPE_LINES
*        PRESENTATION_TYPE =  gfw_prestype_time_axis
*        PRESENTATION_TYPE = gfw_prestype_area
*        PRESENTATION_TYPE = gfw_prestype_horizontal_bars
TABLES
VALUES            = Y_VALUES
COLUMN_TEXTS      = X_TEXTS
EXCEPTIONS
ERROR_OCCURRED    =
1
OTHERS            = 2.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------
MODULE USER_COMMAND_0100 INPUT.
case ok_code.
when'BACK'.
leavePROGRAM.

endcase.

ENDMODULE

 

The output is the graph above.

 

Multiple Line Charts

Now suppose  you want to compare the revenues of two different departments. You need a line chart, one for each department. To achieve this simply insert one more row to the y values tables.

 

DATA: Y_VALUES       TYPETABLEOF GPRVAL WITHHEADERLINE,
X_TEXTS       
TYPETABLEOF GPRTXT WITHHEADERLINE.
data Ok_code like sy-ucomm.

REFRESH Y_VALUES.
REFRESH X_TEXTS.

Y_VALUES-ROWTXT =
'Revenue - Dept1'.
Y_VALUES-VAL1 =
5000.
Y_VALUES-VAL2 =
8000.
Y_VALUES-VAL3 =
3000.
Y_VALUES-VAL4 =
10000.
APPEND Y_VALUES.

Y_VALUES-ROWTXT =
'Revenue - Dept2'.
Y_VALUES-VAL1 =
6000.
Y_VALUES-VAL2 =
7000.
Y_VALUES-VAL3 =
6000.
Y_VALUES-VAL4 =
5000.
APPEND Y_VALUES.

X_TEXTS-COLTXT =
'2009'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2010'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2011'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'2012'.
APPEND X_TEXTS.

 

 

 

 

Horizontal bar chart.

 

To view the same comparison in bar charts, just change the parameter passed to the presentation type parameter of the function module.

 

CALLFUNCTION'GFW_PRES_SHOW'
EXPORTING
CONTAINER         =
'CONTAINER'  

PRESENTATION_TYPE = gfw_prestype_horizontal_bars
TABLES
VALUES            = Y_VALUES
COLUMN_TEXTS      = X_TEXTS
EXCEPTIONS
ERROR_OCCURRED    =
1
OTHERS            = 2.

 

 

 

\Vertical Bar Chart

 

CALLFUNCTION'GFW_PRES_SHOW'
EXPORTING
CONTAINER         =
'CONTAINER'  

         PRESENTATION_TYPE = gfw_prestype_vertical_bars
TABLES
VALUES            = Y_VALUES
COLUMN_TEXTS      = X_TEXTS
EXCEPTIONS
ERROR_OCCURRED    =
1
OTHERS            = 2.

 

 

Pie Charts.

 

There is slight variation in the input table contents of pie charts for the very reason that the purpose of pie chart is different.

 

Suppose your requirement is to know the contribution of each department to the total revenue, the answer is a pie chart.

 

To draw pie chart, the different departments are added to the text table X_TEXTS (which will be the input to parameter column_texts of the function module ) and the values, that is revenue, contributed by each department goes to the values table Y_VALUES (input table to parameter values of the table. There can be only one row for the Y_VALUES table for the pie chart. 

 

DATA: Y_VALUES       TYPETABLEOF GPRVAL WITHHEADERLINE,
X_TEXTS       
TYPETABLEOF GPRTXT WITHHEADERLINE.
data Ok_code like sy-ucomm.

REFRESH Y_VALUES.
REFRESH X_TEXTS.

X_TEXTS-COLTXT =
'Dept A'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'Dept B'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'Dept C'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'Dept E'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'Dept F'.
APPEND X_TEXTS.
X_TEXTS-COLTXT =
'Dept G'.
APPEND X_TEXTS.

Y_VALUES-VAL1 =
5000.
Y_VALUES-VAL2 =
5500.
Y_VALUES-VAL3 =
3000.
Y_VALUES-VAL4 =
4000.
Y_VALUES-VAL5 =
5000.
Y_VALUES-VAL6 =
6000.
Y_VALUES-VAL7 =
7000.
APPEND Y_VALUES.

 

CALLFUNCTION'GFW_PRES_SHOW'
EXPORTING
CONTAINER         =
'CONTAINER'

          PRESENTATION_TYPE =  gfw_prestype_pie_chart
HEADER            = 'Departmental Analysis of Revenue'
TABLES
VALUES            = Y_VALUES
COLUMN_TEXTS      = X_TEXTS
EXCEPTIONS
ERROR_OCCURRED    =
1
OTHERS            = 2.

 

 

GRAPH_3D / GRAPH_MATRIX* SERIES

The main function modules used in this series are

  • Ø GRAPH_MATRIX
  • Ø GRAPH_MATRIX_2D
  • Ø GRAPH_MATRIX_3D
  • Ø GRAPH_MATRIX_4D

 

All these function modules are similar. These FM may appear more complex, however, they offer more features than the previous FM, like sending graph as mail, setting window size etc. An advantage in using these function modules is that you don’t have to create a container in screen painter to see the output.

 

'GRAPH_MATRIX_3D' "Structure of 3D graphics (user-friendly version)

* EXPORTING

*   auto_cmd_1 = SPACE          "               DO NOT USE

*   auto_cmd_2 = SPACE          "               DO NOT USE

*   col1 = SPACE                "               Column 1

*   col2 = SPACE                "               Column 2

*   col3 = SPACE                "               Column 3

*   col4 = SPACE                "               Column 4

*   col5 = SPACE                "               Column 5

*   col6 = SPACE                "               Column 6

*   dim1 = SPACE                "               Name of dimension 1

*   dim2 = SPACE                "               Name of dimension 2

*   inbuf = SPACE               "               DO NOT USE

*   inform = SPACE              "               Allows dialog functions

*   mail_allow = SPACE          "               Allows sending the graphic as mail in SAPoffice

*   pwdid = SPACE               "               Dialog parameters

*   set_focus = 'x'             "               Set focus during reload

*   smfont = SPACE              "               Use smaller fonts = 'X'

*   so_contents = SPACE         "               Subtitle of generated SAPoffice document

*   so_receiver = SPACE         "               Recipient of generated SAPoffice object

*   so_send = SPACE             "               Graphic storage in SAPoffice instead of display

*   so_title = SPACE            "               Title of the generated SAPoffice document

*   stat = SPACE                "               Dialog parameters

*   super = SPACE               "               Dialog parameters

*   timer = SPACE               "

*   timer = SPACE               "              

*   titl = SPACE                "

*   titl = SPACE                "               Title

*   valt = SPACE                "               Scale name

*   valt = SPACE                "

*   wdid = SPACE                "

*   wdid = SPACE                "               see WINID

*   winid = SPACE               "               Dialog parameters

*   winid = SPACE               "

*   winpos = SPACE              "               Window position

*   winpos = SPACE              "

*   winszx = '50'               "

*   winszx = '50'               "               Window size in % / X

*   winszy = '50'               "               Window size in % / Y

*   winszy = '50'               "

*   x_opt = SPACE               "

*   x_opt = SPACE               "              

*   notify = SPACE              "               Activate 'Save settings'

  IMPORTING

    b_key =                     "               Pressed key

    b_typ =                     "               Class for Business Graphics feedback

    cua_id =                    "               Not yet

    mod_col =                   "               Column of selected/modified object

    mod_row =                   "               Line of selected/modified object

    mod_val =                   "               New value of modified object

    m_typ =                     "               Dialog parameters

    rbuff =                     "               DO NOT USE

    rwnid =                     "               Dialog parameters

  TABLES

    data =                      "               Table with text fields and value fields

    opts =                      "               Options table

    .  "  GRAPH_MATRIX_3D

 

All the function modules in this series have more or less the same parameters with slight variations. Among the parameters, only the cols parameter, data table and opts table is compulsory.  Rest is all additional features including setting the size of window (to change the default setting), sending graphic as mail etc.

 

The data table contains the input data for the graph while the ‘opts’ table defines the various settings that you require for your graph. You can pass an empty opts table when the graph will be displayed according to default settings.

 

The opts table will be a character table of the following structure.

data: beginof opts occurs1,
c(80) typec,
endof opts.

 

Depending on the type of chart required, you need to populate this table. This parameter has a huge potential and almost any setting can be appended as a row in this table parameter.

 

Example :

 

The following example outputs a 3D chart for the sales by country for three years. 

 

It uses the FM GRAPH_MATRIX_3D

 

REPORT  ZGRAPHICS.
*
DATA: BEGINOF ITAB_DATA OCCURS0,
YEAR(
15),
SALES1
TYPEI,
SALES2
TYPEI,
SALES3
TYPEI,
ENDOF ITAB_DATA,

BEGINOF ITAB_OPT OCCURS0,
OPTION(
20),
ENDOF ITAB_OPT.

ITAB_DATA-year =
'2010'.
ITAB_DATA-SALES1 =
55.
ITAB_DATA-SALES2 =
62.
ITAB_DATA-SALES3 =
39.
APPEND ITAB_DATA.

ITAB_DATA-YEAR =
'2011'.
ITAB_DATA-SALES1 =
65.
ITAB_DATA-SALES2 =
52.
ITAB_DATA-SALES3 =
44.
APPEND ITAB_DATA.

ITAB_DATA-YEAR =
'2012'.
ITAB_DATA-SALES1 =
38.
ITAB_DATA-SALES2 =
22.
ITAB_DATA-SALES3 =
19.
APPEND ITAB_DATA.

CALLFUNCTION'GRAPH_MATRIX_3D'
EXPORTING

     DIM1   = 'Country'
     DIM2   =
'Years'
      COL1   =
'India'
      COL2   =
'US'
      COL3   =
'UAE'
      TITL   =
'Sales across Countries in Dollars.'
TABLES
     
DATA   = ITAB_DATA
      OPTS   = ITAB_OPT
EXCEPTIONS
     
OTHERS = 1.

 

Output

 

This is the default output with an empty option table.

 

On the top left is the 3 D graph. All the three dimensions, namely Country, Year and Sales quantity can be seen together in the 3D graph. To get a bigger view of the 3 D graph, click on the ‘3D View’ button on the top.

 

The main graph in the lower right corner is the 2D vertical bar graph.  You can change the view of the 2D graph by clicking on the button ‘Left’ or ‘Right’. The 2 D graph stack alternates between Years and Country on doing so.

 

You can make the graph more specific by clicking on the Sel Down or Sel up Button. If 2D graph is grouped by country, it will show the graphs for each country one by one. You can also achieve this by navigating along the stack shown on the left side of the graph.

 

The sales output for the three years only for US is shown on navigating along the stack on the left side to US, or clicking the Sel Down Button Twice.

 

If the graph was grouped by Countries, we would have been able to see the graphs for each year for all countries.

 

 

First selection button alternates between the overall view and specialized view.

 

The Group Button gives a magnified view of 2D graph with each country/ year grouped as an independent graph.

 

This was the output for the FM with the default parameters in the OPT tab. 

 

You can change the appearance of the 2D chart (the color or type of chart) by passing appropriate parameters to the opt table.

 

The following are the different values allowed in the opt parameter for 2D graphs.

 

Parameter for Type of 2D Graph

Parameter
Output

P2TYPE = VB

Vertical Bars

P2TYPE = VS

Stacked Vertical Bars

P2TYPE = HB

Horizontal Bars

P2TYPE = HS

Stacked Horizontal. Bars

P2TYPE = TD

Perspective Bars

P2TYPE = VT

Vertical Triangles

P2TYPE = ST

Stepped Lines

P2TYPE = MS

Stepped Areas

P2TYPE = LN

Lines

P2TYPE = SA

Stacked Areas

P2TYPE = MA

Shaded Areas

P2TYPE = PI

Pie Chart

P2TYPE = TP

Perspective Pie Chart

P2TYPE = PO

Polar Diagram

P2TYPE = PP

Relative Polar

 

The different type of 3D charts possible in the FM module are as below.

 

Parameter for Type of 3D Graph

Parameter
Output

P3TYPE = TO

Towers

P3TYPE = PY

Pyramids

P3TYPE = ED

Walls

P3TYPE = WE

WEDGES

P3TYPE = LI

Strips

P3TYPE = NT

Surface

 

 

Now let us change the above program to output a Pie chart for the 2D graph, and a Pyramid chart for the 3D chart.

 

The only difference is that we populate the options table in addition to the above code. with the settings required.

 

itab_opt-option = 'P3TYPE = PY'" 3D Graph type - Pyramid
APPEND ITAB_OPT.
itab_opt-option =
'P2TYPE = PI'" 2D Graph type - Pie chart
APPEND ITAB_OPT.

*itab_opt-option = 'FIFRST = 3D '." First graph to display- 3D View

*APPEND ITAB_OPT.


CALLFUNCTION'GRAPH_MATRIX_3D'
EXPORTING
COL1   =
'India'
COL2   =
'US'
COL3   =
'UAE'
TITL   =
'Sales across Countries in Dollars.'
TABLES
DATA   = ITAB_DATA
OPTS   = ITAB_OPT
EXCEPTIONS
OTHERS = 1.

 

Output

 

We can also set the parameter for the first screen to be displayed. In the default settings, the Overview screen was displayed. Passing one of the following parameters, we can set a particular graph output to be displayed first. For example when we pass the parameter, ‘FIFRST = 3D’, it’s the magnified 3D view that is shown first on executing the transaction and we can see the other graphs by pressing the overview button.


Parameter for the First Graph to be displayed.

Parameter
Output

FIFRST = 2D

2D View  (The output for 2D View button on the Overview Screen)

FIFRST = 3D

3D View  (The output for 3D view button on the Overview Screen)

FIFRST = PU

Graph for the first component on the current stack is displayed first ( In the example, 2010, ie, the output on clicking the Sel up/ Sel Down button on the Over view screen.)

FIFRST = GP

Groups (Output for Groups Button on the Overview Screen)

DTDORD = 2134

The graphs on the right stack will be displayed first. (In the example, the stack with Countries would be displayed, ie the output on Clicking the Right or Left button on the Overview Screen.)

 

The color of the graphs can also be changed with the following parameters

 

Parameter
Output

CLPALT = A

Blue

CLPALT = B

Yellow

CLPALT = C

Green

CLPALT = D

Gray

CLPALT = E

Dot Matrix Printer

CLPALT = F

PostScript

 

There are various other options available like the coloring scheme for the 3D graphs, background, 3 D effects, title, window size, which can be set by passing appropriate parameters in the table.

For more options available in this, refer the following link.

 

http://wiki.scn.sap.com/wiki/display/Snippets/Graph+Parameters

 

Note : The 2D graph options and 3D graph options can be used if you are calling GRAPH_MATRIX_3D FM, however only the options for 2D graph can be passed as parameters when GRAPH_MATRIX_2D FM is used.

 

GRAPH_MATRIX_4D.

 

With Graph_MATRIX_4D function module, I can add one more dimension to the graph. And then I can navigate the 2D and 3D graph for each value in the 4th Dimension by clicking on the Up and Down button.

 

The output looks similar to the output from the previous function with 3D graph at the top and 2D graph at the bottom

 

In the 3D graph, the fourth dimension is shown with colors.

 

In the previous program, if we want to give the sales comparison based on products also, I use this function module.

 

The output would be

 

Here in the 2D graph (bottom-right), the pzroduct Cosmetics is selected on the stack. The X axis, shows the Countries, the years are differentiated by the three colors. To see the graph for other products, just navigate along the products on the stack or click on the ‘Sel Up’ or ‘Sel Down’ Button above. It appears as if you are turning the pages of the book.


The y axis shows the sales for that particular combination.

 

The X axis and the color parameters can be alternated using the ‘Left’ or ‘Right’ Button at the top. On clicking them, the colors shows sales based on country and the years would be regulated along the x axis and vice-versa

 

The Groups button will show all the groups at on shot.

 

The 3D graph can be magnified on clicking the 3D button.



A

As can be seen, all the four dimensions are visible in this graph, using the x, y and z co-ordinates and the color code.

 

The colors on the graph can be enable or disabled by clicking the Stack On/Off Button.

 

Again, as was mention for the previous function module, using the appropriate parameters in the opts table, you can change the 2D graph to pie chart, horizontal bar chart etc. 3D chart type can also be changed according to the requirements. (Refer the parameter list provided above).

 

Now to get the above output, there are very few changes that need to be made to the function module compared to the 3D function.

 

When declaring the internal table, we obviously need to enter more values since there are four dimensions. However for the first dimension, a minimum of six fields must be entered in the internal table type, whether we require it or not.

 

types: BEGINOF ITAB_type,
PROD(
15),
IN10
TYPEI,
IN11
TYPEI,
IN12
TYPEI,
IN13
TYPEI,
IN14
TYPEI,
IN15
TYPEI,
US10
TYPEI,
US11
TYPEI,
US12
TYPEI,
US13
TYPEI,
US14
TYPEI,
US15
TYPEI,
UA10
TYPEI,
UA11
TYPEI,
UA12
TYPEI,
UA13
TYPEI,
UA14
TYPEI,
UA15
TYPEI,
ENDOF ITAB_type.

data : itab_data typetableof itab_type withHEADERLINE,

BEGINOF ITAB_OPT OCCURS0,
OPTION(
20),
ENDOF ITAB_OPT.

ITAB_DATA-prod =
'Cosmetics'.
ITAB_DATA-IN10 =
55.
ITAB_DATA-IN11 =
20.
ITAB_DATA-IN12  =
40.
ITAB_DATA-US10  =
30.
ITAB_DATA-US11  =
15.
ITAB_DATA-US12  =
54.
ITAB_DATA-UA10  =
18.
ITAB_DATA-UA11  =
26.
ITAB_DATA-UA12  =
35.
APPEND ITAB_DATA.

ITAB_DATA-prod =
'Confectionaries'.
ITAB_DATA-IN10 =
35.
ITAB_DATA-IN11 =
40.
ITAB_DATA-IN12  =
50.
ITAB_DATA-US10  =
20.
ITAB_DATA-US11  =
13.
ITAB_DATA-US12  =
51.
ITAB_DATA-UA10  =
12.
ITAB_DATA-UA11  =
24.
ITAB_DATA-UA12  =
85.
APPEND ITAB_DATA.

ITAB_DATA-prod =
'Stationery'.
ITAB_DATA-IN10 =
25.
ITAB_DATA-IN11 =
60.
ITAB_DATA-IN12  =
20.
ITAB_DATA-US10  =
40.
ITAB_DATA-US11  =
15.
ITAB_DATA-US12  =
64.
ITAB_DATA-UA10  =
78.
ITAB_DATA-UA11  =
16.
ITAB_DATA-UA12  =
15.
APPEND ITAB_DATA.
* Grpah options
*itab_opt-option = 'P3TYPE = PY'.  " 3D Graph type - Pyramid
*APPEND ITAB_OPT.
*itab_opt-option = 'P2TYPE = PI'.  " 2D Graph type - Pie chart
*APPEND ITAB_OPT.
*itab_opt-option = 'FIFRST = PU '. " First graph to display - First graph on stack
*APPEND ITAB_OPT.
*itab_opt-option = 'DTDORD = 2134'. " The graphs on the right stack will be displayed first.
*APPEND ITAB_OPT.
*itab_opt-option = 'FISTK3 = X'.
*APPEND ITAB_OPT.


CALLFUNCTION'GRAPH_MATRIX_4D'
EXPORTING
*   AUTO_CMD_1        = ' '
*   AUTO_CMD_2        = ' '
DIM1              =
'Country '
DIM1_1            =
'India '
DIM1_2            =
'US'
DIM1_3            =
'UK '
*   DIM1_4            = ' '
*   DIM1_5            = ' '
*   DIM1_6            = ' '
DIM2              =
'YEAR'
DIM2_1            =
'2010'
DIM2_2            =
'2011'
DIM2_3            =
'2012'
*   DIM2_4            = ' '
*   DIM2_5            = ' '
*   DIM2_6            = ' '
DIM3              =
'Products'
*   MAIL_ALLOW        = ' '
TITL              =
' Sales Comparison'
TABLES
DATA              = ITAB_DATA
OPTS              = ITAB_OPT. 

 

In the function module, DIM1, DIM2, and DIM3, defines the three dimensions of the graph, namely Country, Year and Products. The fourth dimension, Sales, is reflected from the Title of the Graph. The values for DIM1 (Country) are provided in the function modules as parameters, DIM1_1, DIM_2, DIM_3. The values in DIM2 (Year) is also similarly provided in the module. The Values in Dimension 3 (Products) is provided in the data table as the first column in each row appended.

 

        More advanced features can be achieved through the class CL_GFW.

Use transaction GRAL to explore into the various possibilities and features available in ABAP for graphical charts.  

 

I hope that makes drawing graphs with ABAP complete and easily achievable. You can now confidently tell the client, ‘You say it, we got it!’

 

Enjoy drawing graphs on ABAP! 


RTTS –Use Case 1 : A Generic program to upload data into a ztable from an excel file.

$
0
0

Common Approach

  1. Create a local type structure or DDIC structure to match the columns of the excel sheet.
  2. Crate an internal table of the DDIC structure.
  3. Use FM TEXT_CONVERT_XLS_TO_SAP to read data from excel into internal table
  4. Now the entire excel data is internal table which allows us to perform validation, map the internal table data to a ZTABLE structure and update the data into ztable.


The only disadvantage is that the program is not generic and it is specific to that ztable and the excel format.  However, a cleaner approach would be to Use RTTS. The advantage of using RTTS in this case is:

  1. The program can be used to load data to any ztable. It is not specific to any ztable.
  2. The program need not be changed even if a new field is added or removed from the ztable.
  3. We do not need change the program even if column is added or removed from the source excel file.  The source structure and internal table is created dynamically.

 

Simple Selection Screen with two parameters in it.

 

*parameter for table name and file path.
PARAMETERS : p_tabnam TYPE tabname16,
p_filep
TYPE rlgrap-filename.

 

Declaration :

*required type pool

 

TYPE-POOLS abap .

 

*variables to store the structure of the table

 

DATA : lit_component_table TYPE  cl_abap_structdescr=>component_table,
       lwa_component_table
LIKE LINE OF lit_component_table.


* reference variables to structure and table class


DATA lref_struct TYPE REF TO cl_abap_structdescr,
      lref_table
TYPE REF TO cl_abap_tabledescr.

 

*variables to be create dynamically

 

DATA : lit_table TYPE REF TO data.

 

*field symbol to store data

 

FIELD-SYMBOLS : <lf_table> TYPE table.

 

DATA : lv_message TYPE string.

 

START-OF-SELECTION

*we will use the describe by name method and get components to find the list of fields in the table.

lref_struct ?= cl_abap_structdescr=>describe_by_name( p_name = p_tabnam ).

lit_component_table = lref_struct->get_components( ).

 

TRY.
*create a new structure based on the fields. If required new columns can be added/removed to this table.
lref_struct
= cl_abap_structdescr=>create(
                     p_components
= lit_component_table
).

* create a new internal table based on the structure created.

lref_table
= cl_abap_tabledescr=>create(
p_line_type 
= lref_struct
*    p_table_kind = TABLEKIND_STD
*    p_unique     = ABAP_FALSE
*    p_key        =
*    p_key_kind   = KEYDEFKIND_DEFAULT
).
*
CREATE DATA lit_table TYPE HANDLE lref_table.


ASSIGN lit_table->* TO <lf_table>.

CATCH cx_sy_table_creation INTO lref_ex_table. "Exception when Creating a Table Type
lv_message
= lref_ex_table->get_text( ).

ENDTRY.

*using this field symbol we will call the below method to read data from excel. If needed we can use other FM’s or method to read data from excel.


IF lv_message IS INITIAL AND <lf_table> IS ASSIGNED.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
*     I_FIELD_SEPERATOR          =
i_line_header             
= 'X'
i_tab_raw_data            
= lv_text_data
i_filename                
= p_filep
TABLES
i_tab_converted_data      
= <lf_table>
*   EXCEPTIONS
*     CONVERSION_FAILED          = 1
*     OTHERS                     = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.



ENDIF.

*since this is a demo program we are directly modifying the data using the modify statement. In a real scenario we would need to validate, enqueue and then update the data 


MODIFY (p_tabnam) FROM TABLE <lf_table>.

IF sy-subrc eq 0.

     COMMIT WORK.

ENDIF.

Create a Job with Distribution List

$
0
0

Ok, I know it needs a bit of cleaning up!  I'll get to that.  In the meantime, I wanted the OP to have it available...

 

FORM create_job .

 

  DATA : jobname TYPE tbtcjob-jobname VALUE 'Z_RDC_867_LOAD ',

         jobclass TYPE tbtcjob-jobclass VALUE 'C',

         jobcount TYPE tbtcjob-jobcount,

         lv_startdate LIKE sy-datum,

         lv_starttime LIKE sy-uzeit,

         authcknam TYPE tbtcjob-authcknam,

*         lv_varname TYPE rsvar-variant,

         lwa_vardesc TYPE varid .

 

  DATA: BEGIN OF gt_varid.

          INCLUDE STRUCTURE varid.

  DATA: END OF gt_varid.

 

  DATA: BEGIN OF gt_varit OCCURS 2.

          INCLUDE STRUCTURE varit.

  DATA: END OF gt_varit.

 

  DATA: BEGIN OF gt_rsparams OCCURS 0.

          INCLUDE STRUCTURE rsparams.

  DATA: END OF gt_rsparams.

 

  DATA  wa_recipient LIKE swotobjid.

 

*  break nwilhite.

 

  PERFORM get_distribucion_list USING    'Z_XXXXXXX'   " name of List of distribution

                                CHANGING wa_recipient.

 

  authcknam = sy-uname.

 

  lv_startdate = sy-datum.

  lv_starttime = sy-uzeit + 300.

 

*  CONCATENATE  'ABAP' lv_starttime INTO lv_varname.

 

  lwa_vardesc-report = 'Z_YYYYYYYYYY'.

 

  CALL FUNCTION 'JOB_OPEN'

    EXPORTING

      jobname          = jobname

      jobclass         = jobclass

    IMPORTING

      jobcount         = jobcount

    EXCEPTIONS

      cant_create_job  = 1

      invalid_job_data = 2

      jobname_missing  = 3

      OTHERS           = 4.

 

  IF sy-subrc = 0.

 

    CALL FUNCTION 'JOB_SUBMIT'

      EXPORTING

        authcknam               = 'BATCH_JOBS' "authcknam

        jobcount                = jobcount

        jobname                 = jobname

        report                  = 'Z_YYYYYYYYYY'

        variant                 = 'INITIAL_LOAD'

      EXCEPTIONS

        bad_priparams           = 1

        bad_xpgflags            = 2

        invalid_jobdata         = 3

        jobname_missing         = 4

        job_notex               = 5

        job_submit_failed       = 6

        lock_failed             = 7

        program_missing         = 8

        prog_abap_and_extpg_set = 9

        OTHERS                  = 10.

 

    IF sy-subrc = 0.

 

 

* Jobstep to update Margin prices

 

      CALL FUNCTION 'JOB_CLOSE'

        EXPORTING

          jobcount             = jobcount

          jobname              = jobname

          strtimmed            = 'X'

*         sdlstrtdt            = '99991231'

*         sdlstrttm            = '010000'

          recipient_obj        = wa_recipient

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          invalid_target       = 8

          OTHERS               = 9.

 

     ENDIF.

 

  ENDIF.

 

ENDFORM.                    " CREATE_JOB

Client Dependent vs Client Independent

$
0
0

In SAP, highest level of organization structure is client. Whenever we login to SAP system, we login to a specific client. Data in the R/3 system is categorized as client-dependent and client-independent. I have collected some details about Client Dependent vs Client Independent concept of SAP.

 

Client dependent data means the data which user creates in one client is limited to that client only and it is not accessible in other clients

Client Independent means data means the data which user creates in one client that is available in that as well as in other clients

 

Client Dependent Table

  • They have first field called MANDT of type CLNT which contains the client number.
  • The data set can be different in this type of table for different client.

Client Independent Table 

  • They don’t have that MANDT field in table. 
  • This Table is called cross client table means for all the clients they have the same entries in the table.

Examples:

  • Client Dependent: SAPscript and STD texts data
  • Client Independent: Smart forms, all dictionary objects data and repository objects data like programs, function modules, tables etc.

Smart Forms are Client Independent because when you activate them you are actually generating a Function Module. This means that the Print Programs actually call a FM instead of using the “OPEN_FORM”, “WRITE_FORM” etc. FM’s that SAPscript use.

 

There is no specific reason behind why SAPscripts are designed as client dependent and smart forms as client independent!

 

SAPscript technology is based on a mainframe product from the 1980s. SAPscript forms have always been — under the hood — relatively passive objects, with minimal embedded logic. These forms were designed to be driven and controlled by ABAP programs, much in the way ABAP programs read in database tables to produce reports; if you ever download a SAPscript form (e.g., via utility program RSTXSCRP), and look at the portable text file it produces. Many text objects (e.g., invoice header texts) are bound directly to documents which are client-dependent, so it makes sense for these text objects to also be client-dependent. From a complexity standpoint, SAPscript forms are close enough to these text objects where we can see how it made sense at the time to make them client-dependent too. Sap script was developed a long back and Smart form is developed to avoid these types of some restrictions.

 

The ABAP editor is client independent. This means that a program, once created, will be available in all the clients of the system. The data that the program tries to access, though, is client dependent.

 

Understanding Client-Dependent and Client-Independent Tables

There are two types of tables in an R/3 database: client-dependent and client-independent. A table is client-dependent if the first field is of type CLNT. The length will always be 3, and by convention, this field is always named MANDT. If the first field is not of type CLNT, the table is client-independent.

 

For example: assume there are two clients in system – 800 and 900. A program selects rows from table LFA1 and writes out LFA1-LIFNR. When this program is run in client 800, only those rows are selected where MANDT equals 800. This happens automatically because the first field in the table is of type CLNT. If the user were to log on to client 900 and run the same program, those rows of data would be found and written out where client is 900.

The logon client mechanism divides the rows within a client-dependent table into distinct groups. To access a different set of data, the user logs on and specifies a different client number.

 

NOTE: The user master records (containing R/3 user IDs) are client-dependent. Therefore, to gain access to a client, the security administrator must create a new user ID for you within that client.

 

Developers and testers use the logon client mechanism to create and access multiple, independent sets of data within a single table.

 

For example: assume two typical programmers are working on an enhancement to the billing system. User-1 is modifying the update transaction and is creating a new report to go with User-2′s modifications.

 

User-2 sets up data for his test run, executes his report and obtains output. User-1 works in the next cubicle, but due to lack of communication he is not aware that his transaction uses the same tables as User-2′s report. He runs his transaction and updates the data. User-1 gets what he wanted, but User-2 then modifies his code and runs his program again. His output differs from the last run, and the differences many not result from his changes, but rather they may result from User-1′s changes. What we have here is a failure to communicate.

 

If the tables used by User-1 and User-2′s programs were client-dependent, they could each log in to separate clients, set up independent sets of data, and test their programs without ever talking to each other. They could perform all of their testing in the comfort of their cubicles and in isolation from their coworkers.

 

To make their tables’ client-dependent, they only need MANDT as the first field and the R/3 system will take care of the rest. When records are added to the table, the system automatically moves the current logon client into the MANDT field when the record is send to the database. Their Open SQL select statements will only return rows where the client number in the table is equal to their current logon client number. The Open SQL database statements insert, update, modify, and delete also provide automatic client handling.

 

If the tables involved are all client-dependent, there can be more than one group of testers working at a time in one test system. Two teams of testers can test divergent functionality in the same set of programs at the same time provided they log on to different logon clients. The updates done by one team will not change the data belonging to the other team.

 

A training client could also exist on the test system. The students could log on to one client and the testers could log on to another. Both would run the same set of programs, but the programs would access independent sets of data.

 

NOTE: The average R/3 installation has three systems: development, test, and production. By default, each system comes with three clients installed: 000, 001, and 066. It is common to have from three to six clients in the development and test systems, but rarely will you see more than one client in production.

 

(Source - Different SDN forum discussions and SAP help)

BDT IN BP ( PART - I )

$
0
0

1.- Implement the CI_EEW_BUT000 include from table BUT000 

 

imagen1.JPG

2.- Once we've implemented the include, go to se80 transaction and create a function group

imagen2.JPG

3.- Create dynpro 9001 and design the required layout. Component names must match the fieldnames from the include implemented before

imagen3.JPG

4.- At the top include declare the following

imagen4.JPG

5.- In the PBO section insert the following code

imagen5.JPG

6.- Create a routine to fill values into the combo box that has been created in the layout

imagen6.JPG

 

7.- In the PAI section insert the following code

imagen7.JPG

8.- Go to Business Partner Menu through BUPT t-code. Then go to BUS1 transaction.

imagen8.JPG

 

9.- Create a new application entry. Choose an application Id and write the description.

imagen9.JPG

10.- Go back to the BP menu and go to BUS23 transaction.

imagen10.JPG

11.- Create a new data set entry. Choose an Id view and write the description.

imagen11.JPG

12.- Go back and enter bus2 transaction.

imagen12.JPG

13.- Create a new field group entry. Choose ID and description.

imagen13.JPG

14.- The following screen will appear. Complete the fields as shown in the next image.

imagen14.JPG

15.- Add new entries. Those must match the fields that have been created on the include CI_EEW_BUT000

imagen15.JPG

16.- In bupt menu, go to BUS3

imagen16.JPG

17.- Add a new view

imagen17.JPG

18.- When creating a new view you should enter the following values

imagen18.JPG

19.- Once the view has been created. Assign the fieldgroup to the view.

imagen19.JPG

20.- In bupt menu, go to BUS4.

imagen20.JPG

21.- Create a new section.

imagen21.JPG

22.- Assign the view to the section.

imagen22.JPG

23.- In bupt menu, go to BUS5.

imagen23.JPG

24.- Create a new screen.

imagen24.JPG

25.- Enter the following values.

imagen25.JPG

26.- Assign the section to the screen.

imagen26.JPG

27.- In bupt menu, go to BUS6.

imagen27.JPG

28.- In the Screen sequences, create a sequence screen.

imagen28.JPG

29.-Assign the screen to the sequence.

imagen29.JPG

30.- Create a screen sequence categories.

imagen30.JPG

Working with Dynamic Radio Buttons

$
0
0

Introduction

The purpose of this document is to display radio buttons dynamically with dynamic texts. There may be cases where radio buttons and its corresponding text needs to be displayed based on the values being fetched from the internal table. Also the number of radio buttons to be displayed depends on the number of entries in the internal table. For those cases, this document provides a solution for implementing the same in both Module pool and Report programming.

 

Scenario

Consider a scenario where the screen needs to be created with the list of Purchase order numbers, selecting one option at a time to navigate to the next screen with the corresponding details of that selected purchase order number.

In this case, we require radio buttons whose texts would be decided only at runtime.

 

Module Pool

Create a screen with maximum number of radio buttons that would be required. Select all the radio buttons. Right click and define a group.

Instead of specifying the radio button name in the Attributes Screen, Create Input /Output fields parallel to the radio buttons to display dynamic texts.

 

Define the name of Input/Output fields W1, W2, W3 which would be used for populating the values at runtime. Note that ‘Output only ‘option should be checked in the Attributes Screen of the Input/Output fields.

 

Include the following code.

 

Data:  tb_ekko type standard table of ekko,
            wa_ekko type ekko,
            rad type char3,
            val type char3,     

            wf_tabix type char2,     

            wf_index type char2.

*Input/output field Declaration

Data:  w1 type char10,
            w2 type char10,
            w3 type char10,
            w4 typechar10.       

Field-symbols: <fs> type any.

                               

PBO Module:

select ebeln zbd1t

          into corresponding fields of table tb_ekko
          from ekko where zbd1t = '7'.
describe table tb_ekko lines sy-tfill.

wf_index  = 1.
loop at screen.
concatenate 'R' wf_index into rad.

*Logic for Displaying radio buttons based on the table value count.

if screen-name = rad.

if wf_index gt sy-tfill.
  screen-active = '0'.
  modify screen.

  wf_index = wf_index + 1.
  continue.

endif.

wf_index = wf_index + 1.
endif.

endloop.

 

*Logic for Assigning values from table to Input/Output Field.

loop at tb_ekko into wa_ekko.
wf_tabix = sy-tabix.
concatenate 'W' tabix into VAL.
assign (val) to <fs>.
move wa_ekko-ebeln to <fs>.
endloop.

unassign <fs>.

 

Report Program:

In case of report programming, the text of the radio button can be changed dynamically using system field %_R1_%_app_%-text,

Where R1 is the name of the radio button.


Data: tb_ekko
type standard table of ekko,
          wa_ekko
type ekko.

Define radio_but1.

  parameters :&1 radiobutton group GR1 DEFAULT 'X'.
End-of-definition.

Define radio_but2.

  parameters :&1radiobutton group GR1.

End-of-definition.

radio_but1:R1.
radio_but2:R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15.

Data: rad type char3,

          wf_index type char2,
          temp
type char20,
          temp1
type char2.
Field-symbols: <fs>
type any.
At selection-screen output.

select ebeln ZBD1T
         
into corresponding fields of table tb_ekko
         
from ekko where zbd1t = '7'.
describe table tb_ekko lines sy-tfill.

wf_index = 1.

loop at screen.

concatenate 'R' wf_index into rad.

*Logic for Displaying radio buttons based on the table value count.

if screen-name = rad.

if wf_index gt sy-tfill.
screen-active = '0'.
modify screen.

wf_index = wf_index + 1.
continue.

endif.

wf_index = wf_index + 1.
endif.

endloop.

*Logic for Assigning values from table to Input/Output Field.

loop at tb_ekko into wa_ekko.
temp1 = sy-tabix.
concatenate '%_r' temp1 '_%_app_%-text' into temp. 

assign (temp) to <fs>.

move wa_ekko-ebeln to <fs>.
endloop.

unassign <fs>.

Virtual Private Cloud with VPN Access for SAP Trials provided as Virtual Appliance

$
0
0

In this tutorial I’m showing all the steps required to set up a virtual private cloud (VPC) on AWS with VPN access for your trial instances provided as virtual appliances by the SAP Cloud Appliance Library. The proposed setup consists of a VPC with internet gateway, an Open VPN access server in the public subnet of the VPC, and your trial instance in the private subnet of the VPC, as illustrated in the drawing below.

VPC_landscape_01.PNG

Disclaimer

 

Please keep in mind that this is just a proposal to get you started quickly and only one variant how to realize such a scenario in a fairly secure way. There are a lot more installation and configuration options which are not shown below. Thus, this might not be the perfect setup for your personal use case. So please also consider alternative scenarios explained in the VPC documentation. In addition, we always recommend to set up a billing alert for your AWS account to avoid unpleasant surprises.

 

Section 1: Creating the VPC with public and private subnet

 

As a prerequisite for this section I assume that you already have a valid Amazon Web Services (AWS) account. Otherwise navigate to the AWS homepage and sign up.

  1. Sign in to the AWS console of your AWS account: https://console.aws.amazon.com/console/home
  2. Navigate to the VPC Dashboard and select the region US East.
  3. Click on the Start VPC Wizard button.
  4. Select VPC with a Single Public Subnet Only and click Continue.
    VPC_01.PNG
  5. On the next screen use the default settings (VPC: 10.0.0.0/16; public subnet: 10.0.0.0/24) and click Create VPC.
    VPC_02.PNG
  6. After your VPC has been created navigate to Route Tables in the navigation pane and click on the custom route table associated with your subnet (Main attribute = No).
  7. Besides the local route the custom route table of this public subnet contains a route enabling traffic destined for an IP address outside your VPC via the associated internet gateway.
    route_table_01.PNG
  8. You can verify that the main route table of your VPC only enables the local route but no route to the Internet.
    route_table_02.PNG
  9. Navigate to Security Groups in the navigation pane and click on the default VPC security group and delete all existing inbound and outbound rules and apply the rule changes.
  10. Navigate to Subnets in the navigation pane and click Create Subnet.
  11. Create a private subnet within your existing VPC, choose the same availability zone as your public subnet, but define a separate CIDR block (private subnet: 10.0.1.0/24).
    privateSubnet_01.PNG
  12. Verify that the private subnet is using the main route table which only contains the public subnet as local destination.
    privateSubnet_02.PNG

 

Section 2: Launching the OpenVPN server into the public subnet of your VPC

 

  1. Navigate to the VPC Dashboard and verify that you are still using the region US East.
  2. Click the Launch Instance button and select the Classic Wizard.
  3. Navigate to the AWS Marketplace tab and search for OpenVPN.
    VPNserver_01.PNG
  4. Choose the OpenVPN Access Server, navigate to the Launch with EC2 Console tab and hit the Launch with EC2 Console button in the region US East.
    VPNserver_03b.PNG
  5. Review the AMI details and click Continue in the wizard.
  6. In the Instance Details dialog choose T1 Micro as instance type and select your public subnet (e.g. 10.0.0.0/24) in the EC2-VPC tab. Finally, hit the Continue button.
    VPNserver_05.PNG
  7. On the next screen use the default values and assign a static IP (e.g. 10.0.0.99) to the eth0 network adapter of your OpenVPN server. Then hit the Continue button.
    VPNserver_06.PNG
  8. Review the default storage settings and hit the Continue button.
  9. In the tags dialog enter OpenVPN server as value for the Name key and hit Continue.
  10. On the next screen select Create a new key pair, enter a name and click the Create & Download your Key Pair button. Store this key pair of your instance in a safe place.
    VPNserver_09.PNG
  11. In the Configure Firewall dialog select Create new Security Group, name it OpenVPN and add inbound rules for TCP port 22 (SSH), TCP port 443 (HTTPS for the OpenVPN WebUI) and UDP port 1194 (UDP based VPN) as shown in the screenshot.
    VPNserver_11.PNG
    Important remark: We even recommend to restrict access to these ports to trusted IP addresses, i.e. the IP address range of your company or your ISP.
  12. Hit the Continue button, review your launch configuration and hit the Launch button.
  13. Navigate to Instances in the navigation pane, wait until your instance launched successfully.
  14. Select your OpenVPN server instance and use the Actions menu to Change the Source/Destination check to disabled.
    VPNserver_13.PNG
  15. Now navigate to Elastic IPs in the navigation pane, click the Allocate New Address, and select EIP used in VPC.
    eIP_01.PNG
  16. Select the new EIP address, hit the Associate Address button and select the instance ID and IP of your OpenVPN server. Finally, confirm with Yes, Associate.
    eIP_03.PNG

Section 3: Connecting to your OpenVPN server using SSH

 

  1. Extract the private key from your OpenVPN instance key pair that you downloaded during instance creation. Use PuTTYgen or a similar tool to import the key pair and save the private key as ppk file.
    SSH_01.PNG
  2. Download and install an SSH client like PuTTY for your OS.
  3. Open your SSH client, enter the Elastic IP of your OpenVPN server and load the exported private key file for authentication.
    SSH_03.PNG
  4. Log into your OpenVPN server as root and proceed with the configuration of the OpenVPN server using the default settings. For more information consult the corresponding Quick Start Guide.
    SSH_04.PNG
  5. Now define a password for your OpenVPN admin user (default was openvpn) by running passwd openvpn (or using your username) in the secure shell.
  6. Open the Admin WebUI using https://YourEIP/admin and log in with you admin user.
    openVPN_01.PNG
  7. Navigate to the Server Network Settings and enter the Elastic IP as hostname and verify the other settings according to the screenshot.
    openVPN_02.PNG
  8. Navigate to the VPN Settings and enter both subnets in the Routing section (e.g. 10.0.0.0/24 and 10.0.1.0/24).
    openVPN_03.PNG
  9. Now you are done with the basic configuration of your OpenVPN server, log out of the Admin WebUI and exit the secure shell.
    Remark: For security reasons you can also create non-admin VPN users in the User Management section of the Admin WebUI.
  10. Download and install an OpenVPN client for your OS (if you don’t already have one).
  11. Run the OpenVPN client and test your VPN connection by entering the Elastic IP of your OpenVPN server and log on with your VPN user (e.g. openvpn).
    openVPN_04.PNG
  12. Verify that the VPN connection to your VPC has been established successfully.

Section 4: Launching the trial instance into the private subnet of your VPC

 

As prerequisite for this section I assume that you already purchased your trial solution in the SAP Store and registered your AWS account in the Test Drive Center for the SAP Cloud Appliance Library (CAL TDC) as shown in our video tutorial.

  1. Enter your CAL TDC account and  navigate to the Solutions tab. Activate the trial solution you want to instantiate (if not already done) and hit Create Instance.
  2. In the Define General Properties dialog enter a name, select AWS (Amazon) as IaaS provider, choose us-east-1 as region and select Access From Corporate Network and choose your private subnet (e.g. 10.0.1.0/24).
    CAL_instance_01.PNG
  3. In the Configure Virtual Machine dialog review the Virtual Machine Size (choose the recommended size) and the access points of your instance (defaults should be fine unless you have specific requirements).
  4. In the next dialog set the master password for your trial instance (used for several system users as documented in the corresponding user guide).
  5. In the following dialogs you can configure a schedule (optional) and complement your cost forecast (optional).
  6. Finally review your trial instance properties and hit the Finish button.
    CAL_instance_02.PNG
  7. Store and download the key pair of your trial instance in a safe place. As shown above you can export the private key of your trial instance with PuTTYgen as ppk file.
  8. Wait until the initial provisioning process finished and your trial instance is up and running.
  9. Click on your running trial instance and copy the IP address to your clipboard. For your convenience, add the IP to hostname mapping to your local /etc/hosts file. This enables you to use the hostname of your trial instance in SAP GUI or other local clients.
    hostname_etc_hosts_01.PNG


That’s basically it! Use your VPN client to connect to your VPC and work with your trial instance. For example you can now SSH into your trial instance as root using its private key file or connect via SAP GUI with one of the predefined SAP users. Of course, you can deploy additional systems into the private subnet of your VPC if required.

SCN Trial Editions: SAP NetWeaver Application Server ABAP 7.4

$
0
0

Latest News

Aug 28, 2013: We updated the ABAP on SAP HANA trial edition to AS ABAP 7.4 SP03 on SAP HANA 1.00.63.

 

product_32.png

Get your hands on the latest release of SAP NetWeaver Application Server ABAP, learn more about its new capabilities, the programming language enhancements, and test-drive the SAP development tools for Eclipse!

 

You can choose from different SCN trial editions of SAP NetWeaver Application Server ABAP 7.4: A preconfigured virtual appliance you can easily deploy at a cloud service provider or a classical SCN trial, you can download from the SAP Community Network (planned for Q4 2013). SAP provides this software based on a 90-day trial and evaluation license agreement.

 

SCN Trial as Virtual Appliance

 

The SCN trials of SAP NetWeaver Application Server ABAP 7.4 are provided as virtual appliance by the SAP Cloud Appliance Library (free of charge) and available with two different database flavors, i.e. on SAP HANA (in-memory database) and on SAP MaxDB (classical RDBMS). Both virtual appliances come with a detailed user guide describing how to set up and run these virtual appliances.

 

Light_Bulb_32.pngYou should be familiar with the prerequisites and tutorials on our How-to and FAQ page before you order and run these virtual appliances. We also recommend to set up a billing alert for your AWS charges.

 

 

To get access to these virtual appliances and run them on your own cloud service provider account please visit the SAP Store and use your SCN user to 'purchase' these free trial editions. For questions and feedback please post a message in the corresponding ABAP trial thread.

 

 

tag_cloud_chart_grey_32.png

Get AS ABAP 7.4 on SAP HANA
[Trial Edition]

tag_cloud_chart_32.png

Get AS ABAP 7.4 on SAP MaxDB
[Trial Edition]

 

 

Tutorials and Sample Applications

 

All trial editions come with a pre-configured developer user, pre-installed sample applications and tutorials explaining new capabilities and technologies. The following tutorials are already available:

 

ABAP for SAP HANA reference scenario

The ABAP for SAP HANA reference scenario offers guides and tutorials including a pre-installed sample application which guide you through the E2E development process and provide sample coding leveraging the code-pushdown paradigm on SAP’s in-memory database. For more information please visit the reference scenario home page or directly consult the corresponding how-to guide by Jens Weiler.

 

How to implement an OData service with SAP NetWeaver Gateway

This how-to guide by Andre Fischer describes how to quickly create an OData service with SAP NetWeaver Gateway. You will learn how to create a data model based on a DDIC structure and implement the corresponding services using the OData channel programming model. For more information please download the how-to guide from SCN.

 

How to build SAPUI5/HTML5 applications consuming OData services

This blog by Bertram Ganz describes the end-to-end process required to develop a SAPUI5/HTML5 application user interface (with table, popup and ux3 shell) consuming a local OData service by SAP NetWeaver Gateway. The created OData service is based on the SAP NetWeaver Enterprise Sales and Procurement Model as a pre-installed demo/proxy application that provides a list of products as business data. For detailed instructions please download the how-to guide from SCN.


How to set up and run AS ABAP 7.4 trial instances provided as virtual appliance

$
0
0

The following document references the most important guides and tutorials for creating, running and operating the AS ABAP 7.4 trial instances provided as virtual appliances by the SAP Cloud Appliance Library. For questions and feedback regarding these SCN trial editions please post a message in the corresponding ABAP trial thread.

 

Prerequisites

 

 

Tutorials and Guides

 

  • This step-by-step tutorial shows you how to set up a virtual private cloud (VPC) with VPN access on AWS (Amazon Web Services) and launch your trial instance into the private subnet of this VPC.
  • Watch the following video tutorial [5min] to learn how to get and set up an AS ABAP trial instance in your SAP Cloud Appliance Library account:

  • For detailed information about how to set up your local environment and your local clients and how to connect to your ABAP trial instance you can watch the following video tutorial:

 

Frequently Asked Questions

 

Which countries does the SAP Store currently support, in other words grant me access to these trial editions?

Unfortunately, access to these virtual appliances is limited to all countries supported by the SAP Store. Thus, the currently supported countries are: Australia, Austria, Belgium, Canada, Chile, China, Czech Republic, Denmark, Finland, France, Germany, Greece, Hong Kong, India, Ireland, Isreal, Italy, Japan, Luxembourg, Malaysia, Mexico, Netherlands, New Zealand, Norway, Philippines, Portugal, Romania, Singapore, South Korea, Spain, Sweden, Switzerland, Turkey, United Kingdom, United States, Philippines

 

Is it completely free to use the trial editions of these virtual appliances?

To be precise: SAP offers you to instantiate and run these virtual appliances using the SAP CAL test drive center completely for free (according to the terms and conditions). But you have to pay the charges of your cloud service provider hosting these trial instances (without any involvement of SAP).

 

Do the different trial variants have an impact on the charges of my cloud service provider?

Yes, as an AS ABAP on SAP HANA trial instance requires more virtual CPUs and memory than an AS ABAP on MaxDB trial instance you should use the appropriate instance type/size recommended by the instance creation wizard. This has an impact on the charges of your cloud service provider as shown in the cost forecast of your SAP CAL account.

 

Ok, but how do I find out what my cloud service provider charges for these trial instances?

You have two options:

a) The instance creation wizard of the SAP Cloud Appliance Library offers a detailed cost forecast (you could still cancel the creation process).

b) You can take a look at the Amazon EC2 price list for the recommended instance types: x2.4xlarge (AS ABAP on SAP HANA), m1.large (AS ABAP on SAP MaxDB)

 

So how do I run these trial instances cost-effectively on AWS?

Hosting the trial instances on AWS comprises EC2 services (Elastic Compute Cloud) and EBS services (Elastic Block Store). If you suspend the trial instance there are no costs for EC2 services anymore, but still low costs for EBS services. If you terminate your trial instances, there are also no costs for EBS services anymore. Thus, we recommend to use the 'activate and suspend manually' option, which is part of the instance creation wizard or available within the properties of your existing instance. To be on the safe side, you can also activate a billing alarm in your AWS account.

 

How often do you plan to update the trial editions of these virtual appliances?

We plan to offer a new virtual appliance for every major release and enhancement package of AS ABAP. But we are not going to build and publish new trial appliances for every upcoming support package - maybe some major/important ones.

 

The virtual appliance has been updated, what does this mean for me?

Your existing CAL test drive center subscription is still valid and all created instances remain unaffected. Only if you create a new instance the latest version of the AS ABAP 7.40 trial edition will be instantiated.

 

What's the difference between public network access and corporate network access in the instance creation wizard?

In simplified terms, with the public network option you get a public IP address to directly access your trial instance (no VPN required) with all implications on privacy and security. With the corporate network option you get a private IP address from the IP address range of your Virtual Private Cloud. For more information please consult the EC2 user guide.

How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT Function Module

$
0
0

Many times user may have requirement during uploading the data into SAP as below points.


  • Upload the Long Text into SAP Using Excel Sheet (i.e. here I am explaining about a PO Text in MM Screen).
  • Long Text Readable within text area no need to use horizontal bar

 

l0.png

Screen Shot # 1

 

 

Solution:

 

  •   Create a Copy of “ALSM_EXCEL_TO_INTERNAL_TABLE” SAP Standard Function Module

           into Custom Function Module “YALSM_EXCEL_TO_INTERNAL_TABLE” .

 

 

L1.png

Screen Shot # 2

 

 

L2.png

Screen Shot # 3

 

Create a “Z” Copy of “ALSMEX_TABLINE” and Increase the “Value” Field Size i.e. here I am use 2000 character , you can take as per your requirement .

 

L3.png

Screen Shot # 4

 

 

 

  •   Create Custom Upload Program using above Custom Functional Module.

 

 

 

"Data Declaration

 

  TYPES: BEGIN OF TY_ITAB ,

         MATNR(18)    TYPE C,

         LMAKTX(2000) TYPE C,

         ROW TYPE I,

         TSIZE TYPE I,

         END OF TY_ITAB.



"
Data Declarations - Internal Tables

DATA: I_TAB          TYPE STANDARD TABLE OF TY_ITAB  INITIAL SIZE 0,

       IT_EXLOAD      LIKE ZALSMEX_TABLINE  OCCURS 0 WITH HEADER LINE,

       IT_LINES       LIKE STANDARD TABLE OF TLINE WITH HEADER LINE,

       IT_TEXT_HEADER LIKE STANDARD TABLE OF THEAD WITH HEADER LINE,

       WA             TYPE TY_ITAB ,

       P_ERROR TYPE  SY-LISEL ,

       LEN TYPE I .



"Selection Screen

 

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

PARAMETERS:PFILE TYPE RLGRAP-FILENAME OBLIGATORY, “Excel File Name with Path

           W_BEGIN TYPE I OBLIGATORY,                                      “Excel Row beginning

           W_END TYPE I OBLIGATORY.                                          “Excel End Row     

SELECTION-SCREEN END OF BLOCK B1.

 

AT SELECTION-SCREEN.

  IF PFILE IS INITIAL.

    MESSAGE S368(00) WITH 'Please input filename'. STOP.

  ENDIF.

 

START-OF-SELECTION.

 

REFRESH:I_TAB.

  PERFORM EXCEL_DATA_INT_TABLE.   

  PERFORM EXCEL_TO_INT.

  PERFORM CONTOL_PARAMETER.

 

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PFILE.

  PERFORM F4_FILENAME.

 

“ F4 Help getting Excel File Name with Comlete Path

FORM F4_FILENAME .

  CALL FUNCTION 'F4_FILENAME'

  EXPORTING

    PROGRAM_NAME        = SYST-CPROG

    DYNPRO_NUMBER       = SYST-DYNNR

  IMPORTING

    FILE_NAME                  = PFILE .

ENDFORM. 

 

 

“Read Legacy Data Transfer from Excel using Custom Function Module

FORM EXCEL_DATA_INT_TABLE .

  CALL FUNCTION 'YALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

      FILENAME    = PFILE

      I_BEGIN_COL = '0001'               “Excel Beginning Column           

      I_BEGIN_ROW = W_BEGIN     

      I_END_COL   = '002'                  “Excel End Column    

      I_END_ROW   = W_END                                  

    TABLES

      INTERN      = IT_EXLOAD.

ENDFORM.                    " EXCEL_DATA_INT_TABLE

 

 

 

“Transfer Excel data into internal table

FORM EXCEL_TO_INT .

  LOOP AT IT_EXLOAD .

    CASE  IT_EXLOAD-COL1.

      WHEN '0001'.

        WA-MATNR   = IT_EXLOAD-VALUE.        “Material Number Leading with Zero

      WHEN '0002'.

        WA-LMAKTX   = IT_EXLOAD-VALUE.      “ Material Long Text

    ENDCASE.

    AT END OF ROW1.

      WA-TSIZE = STRLEN( WA-LMAKTX ) .         “Finding String Length using STRLEN

      WA-ROW = IT_EXLOAD-ROW1 .                  “Adding Current Row Num into Internal table    

      APPEND WA TO I_TAB.

      CLEAR WA .

    ENDAT.

  ENDLOOP.

ENDFORM.                    " EXCEL_TO_INT

 

 

“Maintain Header, Item data and pass into “SAVE_TEXT” to save to Long Text

FORM CONTOL_PARAMETER.

  DATA OFF TYPE I VALUE '0'.

  LOOP AT I_TAB INTO WA.

    * Create Header

    IT_TEXT_HEADER-TDID     = 'BEST'.                 “ Text ID for Material Master

    IT_TEXT_HEADER-TDSPRAS  = SY-LANGU .    “ Login Language Key

    IT_TEXT_HEADER-TDNAME   = WA-MATNR.     “Material Number leading with Zero 

    IT_TEXT_HEADER-TDOBJECT = 'MATERIAL'.     “ Text Object

 

 

    MOVE WA-TSIZE TO LEN .    

 

 

    LEN =  LEN / 53  + 1.                                           “Finding Number of Row’s taken by Long Text

 

 

    “ Note :  Number of Row Required for Long Text Display

              = Total length of long text / Number Character’s in one Row + 1 

               Here I am taken 53 number of character in each row ,

               because in Material Master Long Text Area Display 53 Character without using Horizontal Bar . "

 

 

    DO LEN TIMES .

      MOVE '*' TO IT_LINES-TDFORMAT.

      MOVE  WA-LMAKTX+OFF(53) TO IT_LINES-TDLINE.

      SHIFT IT_LINES-TDLINE LEFT DELETING LEADING ' '.

      OFF = OFF + 53 .

      APPEND IT_LINES.

      CLEAR IT_LINES .

    ENDDO.

 

Using SAVE_TEXT Functional Module Save Long Text to SAP

    AT END OF ROW.

      CALL FUNCTION 'SAVE_TEXT'                  

        EXPORTING

          CLIENT                     = SY-MANDT

          HEADER                   = IT_TEXT_HEADER

          INSERT                     = ' '

          SAVEMODE_DIRECT = 'X'

        TABLES

          LINES                        = IT_LINES

        EXCEPTIONS

          ID                              = 1

          LANGUAGE               = 2

          NAME                        = 3

          OBJECT                     = 4

          OTHERS                    = 5.

* Check the Return Code

      IF SY-SUBRC <> 0.

        MESSAGE ID SY-MSGID TYPE SY-MSGTY

            NUMBER SY-MSGNO

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

        EXIT.

      ENDIF.

      CLEAR: WA ,LEN , OFF.

      REFRESH IT_LINES .

    ENDAT.

  ENDLOOP.

ENDFORM.                    " CONTOL_PARAMETER

 

 

  • Output

 

L12.png

Screen Shot # 13

 

 

L13.png

Screen Shot # 14

 

 

l00.png

Screen Shot # 15

 

 

Reference :

 

Note - 933420 - ALSM_EXCEL_TO_INTERNAL_TABLE

 

Source Code Available in Wiki : SAP Community Network Wiki - Code Gallery - How to Upload Long Text into SAP Using Excel Sheet an...

 

 

Regard's

Smruti

 

 

 

 


 


Preparing demo video and linking it in SAP tcode

$
0
0

One of the difficult things about learning any new software system is understanding how to use it. SAP is no exception, especially custom tcodes which each customer organization develops based on their custom requirements. To know about standard SAP tcodes, we can SCN-SAP it or GOOGLE it. But for the custom tcodes, unless the functional guy prepares a pretty decent user manual, it becomes difficult for the end-users to understand how to use them. Also end-users/clients tend to forget how to use a tcode if they don't use it often.This prompted me with an idea of developing video help tutorials for tcodes. I have made use of open source software CamStudioto prepare video tutorials and linked it to the tcodes.

 

Steps:

1) Start the recorder and create demo of the tcode by simulating user actions.

2) Once the complete demo is over, stop the recorder and the video will be saved as an .avi format file.

3) Using the SWF producer that comes with the above software package, convert the .avi format file into flash file .swf.

    Flash files are comparatively smaller in size and can be viewed clearly using a web browser.

4) Once the flash file is prepared, host it in a server and link it to the Z tcode via a button/hyperlink.

5) Finally call the below function with the video URL in your PAI.

 

      CALL FUNCTION 'CALL_BROWSER'

         EXPORTING

           URL                               = 'URL of the flash file'

         EXCEPTIONS

           FRONTEND_NOT_SUPPORTED = 1

           FRONTEND_ERROR                   = 2

           PROG_NOT_FOUND                  = 3

           NO_BATCH                                 = 4

           UNSPECIFIED_ERROR             = 5

           OTHERS                                    = 6.

 

Sample screen shots of CamStudio software and a video recorded using it:

 

CamStudio software screenshots

A.jpg

 

Screen shots of a demo video attached within the tcode

1.jpg

 

2.jpg

 

3.jpg

 

4.jpg

 

5.jpg

BENEFITS:

* This will be very useful for functional guys to teach end-users about the functionality of SAP tcodes when compared to teaching with lengthy user manuals.

* This will be very handy for facilitating change in the mindset of users on migration from legacy systems to new SAP implementation.

 

Cheers,

- K.Arun Prabhu.

Creating EXPAND AND COLLAPSE BUTTON IN SELECTION SCREEN.

$
0
0

In i shall show how to create a expand and collapse button in a selection screen with two blocks.

firstly we  need to go to the table ICON and see what icon is required. We can find the icon text in this table. Which is needed to be written in the code. The main objective is to create this

EXPAND.png

collapse.png

 

To achieve this we have to create global or local variable

gc_collp    TYPE char4     VALUE '@3T@',

gc_exp      TYPE char4     VALUE '@3S@'.

 

This are the Icon in text fields which can be found in the table ICON.

NOW at the INITIALIZATION EVENT we have to write the code:

 

MOVE  gc_collp  TO sscrfields-functxt_02.

   LOOP AT SCREEN.

     IF screen-group1 = gc_a.

       screen-active = 1.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

 



AT SELECTION SCREEN EVENT

we have to write  the code:

 

IF sy-ucomm gc_fc02.

     IF sscrfields-functxt_02 = icon_collapse.

       gv_var = gc_exp.

       MOVE gc_exp TO sscrfields-functxt_02.

     ELSEIF sscrfields-functxt_02 = icon_expand.

       gv_var = gc_collp.

       MOVE gc_collp TO sscrfields-functxt_02.

     ENDIF.

   ENDIF.


*(gc_fc02 is function code FC02 Text for pushbuttons which is generated when we press the collapse button u can hard code is as well)

 

and in the end we need to write in the event at selection screen output:

IF gv_var = gc_exp.

     LOOP AT SCREEN.

       IF screen-group1 = gc_a.

         screen-active = 0.

         MODIFY SCREEN.

       ENDIF.

     ENDLOOP.

   ELSEIF gv_var = gc_collp.

     LOOP AT SCREEN.

       IF screen-group1 = gc_a.

         screen-active = 1.

         MODIFY SCREEN.

       ENDIF.

     ENDLOOP.

   ENDIF.

*(gv_var is the variable in which the icon texts are stored).

 

 

Hope this will help for future purposes..

 

Thanks and Regards

Anurag Sinha.

 




Creation of Custom Kernel BADI and Calling it in a Custom Program

$
0
0

The BADI is an object-oriented enhancement option. The BADI defines an interface that can be implemented by BADI-implementations that are transport objects of their own. The new BADI or Kernel BADI is fully integrated into the Enhancement Framework. Within the Enhancement Framework a BADI is an enhancement option or an anchor point for an object plug-in.

 

Kernel BAdIs Features

  • Are integrated directly in the ABAP Language/Runtime
  • Improved filter support allows non-character filter types and complex filter conditions
  • Enable reusable implementation instances (Stateful BAdI)
  • Control of the lifetime of implementations (BAdI-context)
  • Allow for inheritance of implementations
  • Can be switched by the Switch Framework

 

In this document, I have demonstrated the various steps for creating a Kernel BADI and calling it in our own Custom program.

 

1. First  create a  Enhancement spot from SE18. Kernel Badi's belong to an enhancement spot. 

Enhancement spots carry information about the positions at which enhancement options were created. One enhancement spot can manage several enhancement options of a Repository object. Conversely, several enhancement spots can be assigned to one enhancement option.

 

 

Enter the description and if you want you can assign the new enhancement spot to a composite enhancement spot. Composite enhancement spots are used for the semantic grouping of simple enhancement spots. A composite enhancement spot contains either one or more simple enhancement spots and/or one or more composite enhancement spots of the relevant type. You can use composite enhancement spots to combine simple enhancement spots into meaningful units.

 

 

2. On creating the Enhancement spot, you will be directed to Enhancement Spot Editor. Now we need to create a new BADI Definition.

 

 

 

3. Click on the create BADI button.

 

 

4. You will find certain options for the BADI definitions as below.

 

 

Usability - Multiple use - that is, there can be several active implementations

Limited Filter Use – This makes the BADI Filter-dependent - that is, you apply a filter value to each method called (for example, a country). A different (active) implementation is then called for each value. Possible filter values are characterized by the filter type.

Instance Generation Mode - This property controls the instantiation of the object plug-ins during execution of the statement GET BADI.

The first two specifications define context-free BAdIs.

Newly Created Instantiation - New object plug-ins are created at each execution of the statement GET BADI.

Reusing Instantiation - An object plug-in that was used once in the current internal mode is reused, if it is required more than once.

Context-Dependent Instantiation - A context must be specified for GET BADI. This context controls the instantiation. Only one object plug-in is created for each context and implementing class. Each time there is another GET BADI with the same context, it is reused. A context is an instance of a class that implements the tag interface if_badi_context. The specification takes place in the form of a reference to such an instance.

Fallback Class - Fallback class for a BADI is used if there is no active BADI implementation. This means: The GET BADI command returns a handle to an instance of the fallback class and the respective CALL BADI calls the methods of the fallback class instance. As soon as there is an active BADI implementation, the fallback class is not used any longer at runtime.

 

5. Now we need to add an interface to the BADI. Expand the Node of BADI definition name and double click on node Interface. You can either add existing interface or will be prompted to create.

 


 

6. On clicking ‘Yes’, you will be navigated to the below screen, where you can add a method to the new interface.


Save, activate and comeback to the BADI definition screen and activate the Enhancement Spot.

 

 

7. Next we need to implement the Enhancement spot and BADI. Right click on the BADI definition and select Create BADI Implementation.

 

 

8. First the system will ask for enhancement implantation name. Please enter a name and description.

 

 

9. Next it will ask for BADI Implementation name and Class name for implementing BADI. Enter the names and click ok.

 

 

10. Next we have to implement the interface method. Expand the BADI Definition name and double click on BADI implementation.

 

 

11. You will be directed to the enhancement implementation screen, shown below. Double click on the Interface method and you will be prompted to create implementation for the method.


 

12. On clicking yes, you will be navigated to editor for the method. Add the following code for showing a message or anything as per your requirement. Save it and activate.

 

 

So the BADI definition and implementation part is complete.

 

Next we will see how we can call this Kernel BADI in our Custom program.

 

13. Create or open an existing program in SE38. Point to the line where you need to add enhancement option. Right click and select Create Option.

 

 

14. Give an Enhancement point or section name and Enhancement spot implementation name. Here I have opted an Enhancement point and have entered Enhancement spot implementation name as ‘ZENH_IMP_TEST’ (which we have created before).

 

 

A new line will be added to the existing code as shown below.


 

15. Then add the below code which is shown in the red box below.

 

 

Apart from Classic BADI’s which are been called by Proxy class cl_exithandler, Kernel BADI’s are called directly with the reference to the BADI definition via GET BADI and CALL BADI statements.  That is one of the reasons why Kernel BADI is faster than classic BADI. Also in Classic BADI, while we call it via cl_exithandler,  we use the reference to the interface rather than BADI definition

 

16. Now activate the program and execute it. When the cursor reaches the enhancement point, where the BADI is called it will trigger all the active implementations of that BADI. Here we have only one implementation and that will be triggered, which shows the below message as we have written in the BADI implementation.

 

 

If the program fails to trigger the BADI implementation, please recheck whether everything associated with it is ‘Activated’ after the creation.

 

Thank You.

Viewing all 935 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>