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

Configuring HTTP Content Server (1) - Save printed document (2)

$
0
0

More details

 

 

 

The tables :

 

 

If you go in the table you have specify in the transaction OAC3. You will find a new line.

oam1.png

 

 

 

I don't know the ObjectType or the DocumentType

 

Use a trace: Transaction ST05

You will find some select with the good key.

Trans. OAC2 --> Table TOASP

Trans. OAC3 --> Table TOAOM

 

 

 

I don't have an HTTP Content Server but I would like to archive doc

 

It's possible.

You have to create your Content Repository with a different parameter :

oam1.png

(there is not the part of the CS Admin, because you didn't work with Content Server)

 

 

Now create the table : Trans. SE11, copy the SDOKCONT1 table (activate it)

 

 

Now in OAC3, I will set the Content Repository to Z2.

oam1.png

 

I go back in VA02 to repeat output, and when you will ask to display original :

oam1.png

You can see in the URL the parameter : contRep=Z2

 

The table TOA01 now contains an entry for Z2 :

oam1.png

And the table created for the Content Repository Z2 have the entries :

oam1.png

 

 

 

I want to save all the printed Sales Order

 

At the beginning of the doc. I speak about the transaction VV12. You could configure to generate message with the option Print & Archive.

You can't for the value if your users would like to remove-it. But you could force it in the ABAP of the driver program of the Form.

 

 

 

My user don't want to open the document in the internet browser

 

 

Change your user or go in the transaction OAM1 :

oam1.png

 

You could choose between Internet browser or WebGUI (Dynpro including internet browser)

oam1.png

 

If you choose "Use HTML Control" you will have this kind of window :

oam1.png

 

 

Nothing append, is there a log somewhere

 

Yes, you could check your SM58.

For example, if your HTTP Content Server is down for a time. Go in SM58, you will see all the Archive document waiting for the Content Server. You could relaunch the request to create the data. That means, you don't need to have the HTTP Content Server up all the time.

 

 

 

 

Displaying the document in the GOS

 

 

First the GOS is this icon you could see in some transaction :

 

oam1.png

oam1.png

(The menu could change depending of your SAP release)

 

 

We are in a special case with the transaction VA02 (VA01, VA03), we only need to use parameter ID (SU3) "SD_SWU_ACTIVE". You have to set the value "X"

After that, when you call the VA02 the button will appear.

If you select the line "Attachment list", SAP will list all the document link to the object corresponding to your Sales order.

 

If you want to add this button in other transaction, you need to modify the object corresponding in the SWO1 transaction.

I would like to write a doc about that, but there is already one : Activating Generic Object Services Toolbar in SAP Objects  writes by Abhijeet Kapgate


ABAP Programming Best Practices

$
0
0

ABAP Programming Best Practices

 

Contents

Introduction

Top 10 Rules

Performance Rules


1.     Introduction

 

 

               This document is intended to cover the basics of good ABAP programming for ABAP developers and ABAP learners. In a normal SAP environment we use ABAP to write a code for doing a look-up in transformation or to code function modules to extract data from source systems. This process would generally involve declarations, selection of data, read the selected data to manipulate it or to perform calculations. I have taken into consideration only these basic steps for this document.

 

2.     Top 10 Rules

 

     Rule 1: Use the Code Inspector (CI), the Extended Syntax Check (if code inspector is not available) or ABAP Test Cockpit (ATC) and fix all errors and warnings – respectively P1 and P2 for ATC.

    

     Rule 2: Use the TRY / ENDTRY instead of CATCH / ENDCATCH statement to trap runtime errors and handle them.

    

     Rule 3: Always handle all exceptions of a function module or method call. If the function module/method actually issues messages, handle the exceptions with the default message statement. Otherwise handle them with your own error messages.


      Rule 4: Always check for the deletion flag on key master data tables. LOEVM, LOEKZ, LVORM, etc are some of the Deletion flags.


      Rule 5: Check the return code after every statement that updates it. Check with SY-SUBRC only.

 

      Rule 6: Internal tables must be defined with the appropriate table type based on usage (HASHED, SORTED or STANDARD).


      Rule 7: When using the FOR ALL ENTRIES option in an SQL WHERE clause, you must ensure that the internal table used in the FOR ALL ENTRIES option is not empty, immediately before the SQL statement.

 

      Rule 8: Alway apply lock to a tables before issuing update commands.


      Rule 9: Use Join conditions instead of SELECT....INTO itab with subsequent SELECT.....FOR ALL ENTRIES IN itab, except for buffered tables.


      Rule 10: Don't use INSERT, UPDATE, etc. within loops.

 

3.     Performance Rules

      

       Rule 1: Pass by value in Sub-Routine/Method should only be used when passed data need to be duplicated for specific processing.

    

       Rule 2: Avoid CPU intensive operations during LOOP … ENDLOOP.

   

       Rule 3: ALWAYS process internal tables with field-symbols either using LOOP AT ... ASSIGNING <...> or using READ ... ASSIGNING.

       Rule 4: RFC Calls: Optimize network traffic by architecting the solution with minimized network traffic.

       


 

Note: I will keep updating this document based on further corrections/suggestions.


HR Forms with Adobe Forms

$
0
0

HR FORMS

The HR Forms Workplace enables you to create reports for HR master data, personnel time data, and payroll results with an attractive layout.


HR FORMS Workplace is accessed by the T-Code HRFORMS. This Workplace is categorized into three different sections namely,

  • Overview Screen
  • Data Maintenance Screen (HR Forms)
  • Form Maintenance Screen (Form Builder)

 

HR Forms Workplace


T-Code HRFORMS will navigate us to overview of HR Forms Workplace.

1.png

Figure 1: HR Forms Workplace

Form Creation


HR Form creation involves data selection and form layout separately. In data selection we use MetaNets, InfoNets to select the data that needs to be printed on the form whereas we can select Smartform / Adobeform for the form layout.

 

In this document we make use of the Adobe form to design the layout.

 

Step 1: Create Form

Click on the create button in HR Forms Workplace which opens the create form sub window.

 

Enter the form name, country grouping as per the business requirement and form class depending on the type of form you want to create.

1.png

Figure 2: Create Form

    

You can also make a copy of the existing standard HR Forms within the required country grouping and do changes as per business requirement.

 

STEP 2: InfoNet Maintenance

 

The Form ZHR_PAYSLIP_AU is created and the SAP Standard MetaNet is populated based on the form class selected as in Figure 2.

User defined MetaNet can be created using the T-Code HRFORMS_METADATA.

 

1.png

Figure 3: Change HR Forms

 

Layout Editor can be selected based on the requirement as shown below.

SAP Smart Forms– Design Layout using Smart Forms
Form Builder– Design Layout using Adobe Forms

 

1.png

Figure 4: Layout Editor

 

In the Selection Screen tab, Fields that needs to be displayed can be selected based on the business requirement.

 

1.png

Figure 5: Selection Screen

 

The MetaNet contains MetaStars, MetaStarts contains MetaFields and is displayed in the system as an overview tree. The MetaNet is above the MetaStar in the hierarchy and is country-specific. It contains, for example,

 

  • Infotypes (such as Organizational Assignment (0001) and Basic Pay (0008)) that contain Personnel Administration and Personnel Time Management data.
  • Internal tables (such as RT, BT, and SV) that contain payroll results from the Payroll system.

By Selecting the required fields and using Drag & Drop Feature, the fields get placed in the Infonet Area as shown below. Once the data gets placed in the Infonet Section, they are referred to as Info Stars.

 

1.png

Figure 6: MetaNet, InfoNet

 

The Info Star names can be renamed and corresponding Meta Star name is displayed in the Info Star tab as shown in the Figure 7.

The Meta Field Details which consists of the fields under it can be seen by selecting the Show Details button as shown in the Figure 7.

 

1.png

Figure 7: Show Details

 

Selection Overview can be used to filter the data by providing the selections in the selection table as shown in Figure 8.

 

1.png

Figure 8: Selection Overview

 

This ends up the creation of HR Forms Section . Next step is to proceed for Adobe Form Creation from the HR Forms Workplace.

 

STEP 3: Adobe Form Creation

 

Select the Layout Button, which navigates into the Adobe Forms exiting the HR Forms.

 

1.png

Figure 9: Layout

 

A Form Interface is created for HR Forms using Form Builder (Adobe Forms) as shown in the Figure 10.

 

1.png

Figure 10: Form Properties

 

Double clicking on the interface name will navigate the user to Form Interface where user can write specific code by creating fields in the global data.

 

The interface can also be accessed using the T-Code SFP by entering the interface name.

 

The Form Interface appears as follows, which is divided into Form Interface, Global Definitions, Initialization and Currency/Quantity Fields.

 

Form Interface– To pass the data between the form and interface.

Global Definitions– To make data available in the form.

Initialization– To write the custom code and performs.

Currency/Quantity Fields– To assign a reference to currency/quantity fields

 

1.png

Figure 11: Form Interface

 

In the Context tab, use the drag and drop feature to select the data from Import folder of Interface section to Context section.


Under Global Data folder, the data which is created in the form interface is available.

 

 

 

1.png

 

Figure 12: Context

 

 

Under the context section, right click on the field and set it to active to appear or deactivate not to appear in the form layout as shown below.

 

 

 

1.png

Figure 13: Set to Active / Deactivate

 

Data in the context can be filtered by using the Where conditions and conditions by selecting the field in the context as shown below.

 

 

1.png

Figure 14: Where Conditions

 

Click on the Layout button as shown in Figure 14, which navigates the user to Layout page of the Adobe forms.

 

The Layout page consists of Hierarchy, Data View, Layout Editor, Object Library.

 

Hierarchy– It consists of the hierarchy of the views designed in the form.

Data View– It consists of the data that can be used in the form by drag and drop feature.

Layout Editor– It consists of 3 sub sections
                        1. Design View – Used to design the form which includes tables, images, etc..
                        2. Master Page – Used to design the header, footer which repeats for each page
                        3. Preview – Used to preview the page

Object Library– It is used to set the Layout (Margins, Anchor position, etc…), Border, Object Properties.

 

The Layout page after the design looks as figure below.

 

1.png

Figure 15: Layout

 

After completion, save the layout and activate the form, HR form.

 

STEP 3: Execute the HR Form

 

Execute the HR Form, depending in the Spool Settings the Form is selected from HR Workplace & sent to Spool.

 

1.png

Figure 16: Execute HR Form

 

This ends the process of creating of HR Forms-Adobe Forms.

SAP TM Enhancement Guide 2nd Edition

$
0
0

The document provides the first 5 reworked chapters of the SAP Transportation Management (TM) Enhancement Guide.

View Document

Custom Sub total and totals text using Dynamic internal tables in ALV

$
0
0

Introduction

Dynamic internal tables come into picture in ABAP when the numbers of fields or columns are not known. The concept of internal table applies to the dynamic internal tables too, but just that the rows or columns are dynamic and not static.

Challenges faced in the requirement are:

a)    Display custom subtotal/total texts

b)    Perform difference of the subtotal values to display the difference of 2 subtotal amounts when dynamic internal tables are used.

c)    Color the sub total rows

 

Requirement:

Here, we shall see an example of an ALV display where columns are static and dynamic in nature.

(Limitation: Maximum of 99 columns can be displayed in an ALV).

ALV output to be built should be as seen in the below screen shot. Assume the G/L accounts to be displayed in the output are maintained in a custom table. Hence, based on the number of G/L accounts in the custom table the columns of the ALV are built.

  • Sub totals texts and Total/Difference texts have to be displayed by calculating the amounts from the line items.

sample_display.png 

 

Solution:

  • Firstly, build an internal table with all the required data fetched from the database tables.
  • First column values would be either' Paid' or 'Not paid' (depending on the requirement).
  • Build the field catalog for the static and dynamic columns. For dynamic columns, give a unique field name for referencing during subtotal and total amount calculation.
  • Build the field catalog with color if required for the subtotal and total rows.
  • Once the field catalog is built, the dynamic table can be created with reference to the above built field catalog (gt_fldcat).

  CALL METHOD cl_alv_table_create=>create_dynamic_table
   
EXPORTING
      it_fieldcatalog          = gt_fldcat
   
IMPORTING
      ep_table                  = gt_dtable
   
EXCEPTIONS
      generate_subpool_dir_full =
1
   
OTHERS                    = 2.

  • Using the above call to method ' CREATE_DYNAMIC_TABLE' of class ' CL_ALV_TABLE_CREATE' gt_dtable can be created. Declaration of gt_dtable is shown below.

         

               DATA : gt_dtable    TYPE REF TO data.

 

 

  • Assign the reference of gt_dtable to a field symbol created for the dynamic internal table.

 

     FIELD-SYMBOLS:<gt_dtable> TYPE STANDARD TABLE.

ASSIGN gt_dtable->* TO <gt_dtable>.

 

NOTE: The property of gt_dtable is assigned to <gt_dtable> which is the dynamic internal table.

 

·        To create a work area for the dynamic internal table use the below syntax.

 

The structure of <gt_dtable> is copied to gt_newline and the property of gt_newline is assigned to <fs_dtable> which will act as the work area for <gt_dtable>.

 

DATA : gt_newline  TYPE REF TO data.

 

            CREATE DATA gt_newline LIKE LINE OF <gt_dtable>.
 
        ASSIGN gt_newline->* TO <fs_dtable>.

 

·        To fill the dynamic internal table use ASSIGN COMPONENT syntax and pass the data to a field symbol as shown below.

 

     LOOP AT gt_data INTO f_data. "Table containing the data for display

     ASSIGN COMPONENT <field name> OF STRUCTURE <fs_dtable> TO <w_field>.

     IF sy-subrc IS INTITAL.

       <w_field> = f_data-<field name>.

     ENDIF.

     ....

     ENDLOOP.

 

Calculating sum/difference between different sub-total fields:

 

·        Subtotal amounts have to be calculated based on the values in the BLANK column (Paid or Not Paid) with the help of the fieldnames in field catalog.

 

NOTE: The subtotal values can be obtained from ALV functionality, but as the difference of the subtotals is required we are following this approach. Also, to display user specific subtotal texts this approach is used.

 

·        Store the amounts for each column in a new internal table (this will be useful for calculating the difference for each column).

 

NOTE: Total functionality is available in ALV but not the difference of subtotal values. Hence, here the sub total values are being used for getting the difference amount.

 

·        Fetch the index from the dynamic internal table for BLANK column values as 'Paid' and 'Not Paid' to insert the sub total values and subtotal texts.

 

·        'Net Difference' text and the respective amount can be inserted at the end of the dynamic internal as it has to be the last line in the display.

 

NOTE: A new work area has to be created with the similar structure of gt_fldcat in order to hold the subtotal rows of 'Paid' and 'Not Paid' and the 'Net difference' row.

 

·        Call Function Module ' REUSE_ALV_GRID_DISPLAY_LVC' for the desired output.

 

Sample code for display is given below.

 

·      1)  Create dynamic internal table:

 

DATA : gt_fldcat TYPE lvc_t_fcat,

gt_newline   TYPE REF TO data.

FIELD-SYMBOLS : <gt_dtable> TYPE STANDARD TABLE,

    <fs_dtable> TYPE ANY.

 

*--Create dynamic internal table and assign to FS
 
CLEAR : gt_dtable, gt_newline.
 
CALL METHOD cl_alv_table_create=>create_dynamic_table
   
EXPORTING
      it_fieldcatalog           = gt_fldcat
   
IMPORTING
      ep_table                  = gt_dtable
   
EXCEPTIONS
      generate_subpool_dir_full =
1
     
OTHERS                    = 2.
 
IF sy-subrc <> 0.                                         "#EC NEEDED
  ENDIF.

 
ASSIGN gt_dtable->* TO <gt_dtable>.

 


*--Create dynamic work area and assign to FS
 
CREATE DATA gt_newline LIKE LINE OF <gt_dtable>.
 
ASSIGN gt_newline->* TO <fs_dtable>.

 

 

 

2) Fill dynamic internal table <gt_dtable> using ASSIGN COMPONENT syntax.

 

3) Calculate the index for 'Paid' and 'Not Paid'.

 

*--Calculating index to display sub totals row

ASSIGN COMPONENT 'BLANK' OF STRUCTURE <fs_dtable> TO <w_fld>.

     IF sy-subrc IS INITIAL.

          IF <w_fld> EQ 'Paid'.

            w_ind = w_ind + 1.

          ELSEIF <w_fld> EQ 'Not Paid'.

            w_lin = w_lin + 1.

          ENDIF.

    

     ENDIF.

         ENDLOOP.

 

4) Fetch the subtotal values into a work area and insert them into the dynamic internal table as shown below.

 

Column_name - Name of the column where the sub total text has to be displayed.

 

     ASSIGN COMPONENT '<Column_name>' OF STRUCTURE <fs_tab> TO <w_fld>.

     IF sy-subrc IS INITIAL.

       <w_fld> = 'Paid'.

 

     Color the subtotal row of the dynamic ALV.

      ASSIGN COMPONENT 'CELLCOLOR' OF STRUCTURE <fs_tab> TO <w_fld>.
     
IF sy-subrc IS INITIAL.
        <w_fld> =
'C305'."Yellow

      ENDIF.

    ENDIF.

    w_ind = w_ind +
1.
   
INSERT <fs_tab> INTO <gt_dtable> INDEX w_ind.

 

      5) Display data using the FM below.

 

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
   
EXPORTING
      i_callback_program       = w_repid
      i_callback_pf_status_set =
'STATUS'
      i_callback_user_command  =
'USERCOMMAND'
      is_layout_lvc            = gf_lay
      it_fieldcat_lvc          = gt_fldcat
   
TABLES
      t_outtab                 = <gt_dtable>.

Comment field for Inventory Adjustments

$
0
0

Applies to:

SAP ECC 6.0 EHP 4

 

Summary


There are various options for posting inventory differences depending on the processing status of the physical inventory transaction.

  • Posting differences after the count has been posted
A physical inventory document has already been created, and the count has already been posted. You only have to post the inventory differences.
  • Posting the count and inventory differences simultaneously after the physical inventory document has been created
A physical inventory document has been created, but the count has not yet been posted. The count results are available. You enter the count and post the differences in one step.
  • Entering the count without a document reference

 

You have a count result without reference; that is, no physical inventory document has yet been created for this physical inventory transaction. You create a physical inventory document, enter the count, and post the differences in one step.

SAP provides transactions MI07, MI10 to post inventory difference. These transactions do not provide any ability to user to enter some free text to further explain the need to make any adjustments. For end user, it becomes much more easier to later on understand the reasons of inventory difference, if there is provision to enter free text. Entering comments also help to identify reasons for quant write-offs.

 

This document describes a work around developed in SAP to allow user to enter free text as inventory adjustment reason.

 

Author: Parag Parikh

Company: Deloitte Consulting LLP

Created on: 24th March 2012

Author Bio

 

Parag (2).JPG

 

Parag Parikh is an SAP ABAP, SAP workflow consultant with 4.5 years of experience. He has extensively worked on SAP ABAP and SAP workflow. Parag also has functional skills for SAP FS-CD solution. He has worked on many SAP modules including SAP FI/CO, SD, MM, QM, PP, PLM-RM, SRM, HCM, ESS/MSS and EH&S. Parag is working with Deloitte Consulting LLP as Workflow Specialist.

 

Author: Vamsi Krishna Parepalli   ( SCN ID: E1106724)

Company:    Deloitte Consulting LLP

 

Vamsi Parepalli has over 6 years of experience in SAP ABAP, SAP OO-ABAP. He has extensively worked on Object Oriented ABAP. Vamsi is a techno-functional expert in SAP Retail, SAP SD and SAP MM modules. His experience includes Reports, Enhancements, Forms, Interfaces and Workflow development. Vamsi is also an iRise expert and has developed many pre-sales demo using iRise Visual Simulator. He is currently working with Deloitte Consulting LLP as SAP Technical Consultant in capacity of a process lead and is technically leading iRise initiative. He is also responsible for implementing EH&S and Global Label Management solution for clients.

 

Vamsi.PNG

 

Document Created on: 1st March 2013

 

Requirement:

 

Provide user with ability to enter the free text on the below transaction screens.

 

MI10 – Post Document, Count and Differences: Initial Screen

MI07 – Post Inventory Difference: Initial Screen

 

Challenges:

 

1) SAP does not provide any screen entrancement option (BAdi, customer exit) for both the transactions on initial screen.

2) What if user needs to enter different adjustment comments for each material in stock?

 

Solution Proposed:

 

Instead of initial screen, provide an editable ALV screen when user press SAVE button with details of all materials for which count is adjusted. An assumption is made that reason comment will be less than or equal to 100 characters.

 

If needed the approach can be modified to publish a long text editor in pop-up for each row in ALV to enter long text.

 

Demonstration:

 

Below section describes behavior of enhanced transaction once development was in place.

 

MI10:

 

I. Perform inventory adjustment w/o reference (via MI10)

 

Go to MI10 transaction (Post, Count, and Difference).


1.jpg

Enter the material, batch, inventory count, reason code and save the record.

 

2.jpg

 

Below is new screen created to allow user to enter reason text for each line entered on screen above. For user's reference, the ALV screen also provides Material Description, Plant, Storage Location, Batch, Special Indicator, Stock Type information as well in addition to provision to edit Reason Comment.

 

3.jpg

 

Check the data posted in ISEG table.

 

4.jpg

5.jpg

 

We see that comment is updated in table ISEG in custom field of 100 characters.

6.jpg

II. Create inventory document (via MI01).

 

Create a Physical inventory document in MI01 transaction.

 

2.1.jpg

Enter the material number and the batch and save the inventory record.


2.2.jpg

 

Enter the inventory count in MI04 transaction.

 

2.3.jpg


Enter the inventory count and save the physical inventory document.

2.4.png

 

 

2.6.jpg

Post the inventory difference in MI07 transaction.


2.7.jpg

 

Enter the reason code and hit SAVE.


2.8.jpg

 

Custom screen to enter rejection comments is displayed.

2.9.jpg

III. Execute MI07, using inventory record from case II.

 

Create a System inventory record using transaction LI01.

 

3.1.jpg

Enter the storage bin value and save the system inventory record.


3.2.jpg


3.3.jpg

Activate the record using LI02 transaction.


3.4.jpg

3.5.jpg

 

Enter the count in the inventory record using LI11 transaction.


3.6.jpg

 

3.7.jpg

3.8.jpg

 

Clear the Storage bin associated with the inventory record using LI20 transaction.

 

3.9.jpg

3.10.jpg

3.11.jpg

 

Post the inventory record in LI21 transaction entering the reason code comment.

 

3.12.jpg

3.14.jpg

As shown below, custom screen is displayed to provide reason text. This time user can enter reason for write-off reason for a particular inventory item.

3.15.jpg

3.16.jpg

 

Technical Approach:

 

To create a custom screen, a custom function group can be created. Function Modules inside this Function Group can then call the custom screen using familiar CALL SCREEN command.

 

FM to display ALV:


To display an editable ALV, we can encapsulate ALV code in a FM. create a function group ZFSIM_INV. Create a custom function module ‘ZFSIM_INV_REASON_COMMENT’. Code snippet below provides details on FM implementation.

 

FUNCTION zfsim_inv_reason_comment.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  TABLES

*"      CT_ISEG STRUCTURE  ISEG

*"----------------------------------------------------------------------

TYPES: BEGIN OF ty_mat_text,

         matnr    TYPE matnr,

         maktx    TYPE maktx,

         END OF   ty_mat_text,

         tt_mat_text TYPE STANDARD TABLE OF ty_mat_text.

 

 

  DATA: lt_mat TYPE tt_mat_text.

  FIELD-SYMBOLS: <lfs_mat> TYPE LINE OF tt_mat_text.

 

 

  SELECT matnr maktx

    INTO TABLE lt_mat

    FROM makt

    FOR ALL ENTRIES IN ct_iseg

   WHERE matnr = ct_iseg-matnr

     AND spras = sy-langu.

  IF sy-subrc EQ 0.

    SORT lt_mat BY matnr.

  ENDIF.

 

 

  IF NOT ct_iseg[] IS INITIAL.

    LOOP AT ct_iseg ASSIGNING <lfs_iseg>.

      ls_iseg-zeili = <lfs_iseg>-zeili.

      ls_iseg-matnr = <lfs_iseg>-matnr.

      READ TABLE lt_mat ASSIGNING <lfs_mat>

          WITH KEY matnr = <lfs_iseg>-matnr

          BINARY SEARCH.

      IF sy-subrc EQ 0.

        ls_iseg-maktx = <lfs_mat>-maktx.

      ENDIF.

      ls_iseg-lgort = <lfs_iseg>-lgort.

      ls_iseg-werks = <lfs_iseg>-werks.

      ls_iseg-charg = <lfs_iseg>-charg.

      ls_iseg-sobkz = <lfs_iseg>-sobkz.

      ls_iseg-bstar = <lfs_iseg>-bstar.

      APPEND ls_iseg TO lt_iseg.

      CLEAR ls_iseg.

    ENDLOOP.

    IF NOT lt_iseg[] IS INITIAL.

      PERFORM f_alv_display CHANGING lt_iseg.

    ENDIF.

  ENDIF.

  IF NOT lt_iseg[] IS INITIAL.

    CLEAR ls_iseg.

    LOOP AT lt_iseg INTO ls_iseg.

      READ TABLE ct_iseg ASSIGNING <lfs_iseg> WITH KEY

                 zeili = ls_iseg-zeili.

      IF sy-subrc EQ 0.

        <lfs_iseg>-reas_comm = ls_iseg-reas.

      ENDIF.

    ENDLOOP.

  ENDIF.

 

 

ENDFUNCTION.

 

Top include and subroutine include for the function group:

 

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

*&      Form  F_ALV_DISPLAY

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

*       To display the data in the ALV format

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

*  -->  p1        text

*  <--  p2        text

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

FORM f_alv_display CHANGING ct_iseg TYPE tt_iseg.

  DATA: lt_fieldcat   TYPE slis_t_fieldcat_alv,

        lt_events     TYPE slis_t_event,

        ls_layout     TYPE slis_layout_alv.

*&-- Build Fieldcatalog for ALV display

  PERFORM f_build_fieldcat CHANGING lt_fieldcat.

 

 

*&-- Build the event table for the ALV Display

  PERFORM f_build_events CHANGING lt_events.

*&-- Build the layout table for ALV Display

  PERFORM f_build_layout CHANGING ls_layout.

*&-- Perform to display the output

  PERFORM f_alv_output USING lt_fieldcat

                             lt_events

                             ls_layout

                             ct_iseg.

 

 

ENDFORM.                    " F_ALV_DISPLAY

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

*&      Form  F_BUILD_FIELDCAT

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

*       Building the Fieldcatalog Table for Display of ALV

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

*  -->  p1        text

*  <--  p2        text

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

FORM f_build_fieldcat CHANGING pct_fieldcat TYPE slis_t_fieldcat_alv.

  CONSTANTS: lc_1       TYPE sycucol           VALUE '1',

             lc_2       TYPE sycucol           VALUE '2',

             lc_3       TYPE sycucol           VALUE '3',

             lc_4       TYPE sycucol           VALUE '4',

             lc_5       TYPE sycucol           VALUE '5',

             lc_6       TYPE sycucol           VALUE '6',

             lc_7       TYPE sycucol           VALUE '7',

             lc_8       TYPE sycucol           VALUE '8',

             lc_9       TYPE sycucol           VALUE '9',

             lc_100     TYPE outputlen         VALUE '100',

             lc_zeili   TYPE slis_fieldname    VALUE 'ZEILI',

             lc_matnr   TYPE slis_fieldname    VALUE 'MATNR',

             lc_werks   TYPE slis_fieldname    VALUE 'WERKS',

             lc_lgort   TYPE slis_fieldname    VALUE 'LGORT',

             lc_charg   TYPE slis_fieldname    VALUE 'CHARG',

             lc_sobkz   TYPE slis_fieldname    VALUE 'SOBKZ',

             lc_bstar   TYPE slis_fieldname    VALUE 'BSTAR',

             lc_reas    TYPE slis_fieldname    VALUE 'REAS',

             lc_maktx   TYPE slis_fieldname    VALUE 'MAKTX',

             lc_table   TYPE slis_tabname      VALUE 'PT_ISEG'.

 

 

  DATA: ls_fieldcat TYPE slis_fieldcat_alv.

 

 

  ls_fieldcat-col_pos   = lc_1.

  ls_fieldcat-fieldname = lc_zeili.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l01.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_2.

  ls_fieldcat-fieldname = lc_matnr.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l02.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_3.

  ls_fieldcat-fieldname = lc_maktx.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l09.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_4.

  ls_fieldcat-fieldname = lc_werks.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l03.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_5.

  ls_fieldcat-fieldname = lc_lgort.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l04.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_6.

  ls_fieldcat-fieldname = lc_charg.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l05.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_7.

  ls_fieldcat-fieldname = lc_sobkz.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l06.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_8.

  ls_fieldcat-fieldname = lc_bstar.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-seltext_m = text-l07.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

  ls_fieldcat-col_pos   = lc_9.

  ls_fieldcat-fieldname = lc_reas.

  ls_fieldcat-tabname   = lc_table.

  ls_fieldcat-edit      = abap_true.

  ls_fieldcat-outputlen = lc_100.

  ls_fieldcat-seltext_m = text-l08.

  APPEND ls_fieldcat TO pct_fieldcat.

  CLEAR ls_fieldcat.

 

 

ENDFORM.                    " F_BUILD_FIELDCAT

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

*&      Form  F_BUILD_EVENTS

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

*       Building the Events Table for ALV

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

*      <--P_LT_EVENTS  text

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

FORM f_build_events  CHANGING pct_events TYPE slis_t_event.

  DATA: ls_event TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

      i_list_type = 0

    IMPORTING

      et_events   = pct_events.

 

 

  READ TABLE pct_events WITH KEY name = slis_ev_user_command INTO ls_event.

  IF sy-subrc = 0.

    MOVE 'F_USER_COMMAND' TO ls_event-form.

    APPEND ls_event TO pct_events.

  ENDIF.

ENDFORM.                    " F_BUILD_EVENTS

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

*&      Form  F_BUILD_LAYOUT

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

*       Building the layout setting of the ALV

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

*  -->  p1        text

*  <--  p2        text

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

FORM f_build_layout CHANGING pcs_layout TYPE slis_layout_alv.

  pcs_layout-zebra = abap_true.

ENDFORM.                    " F_BUILD_LAYOUT

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

*&      Form  F_ALV_OUTPUT

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

*       Displaying the ALV GRID Display

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

*  -->  p1        text

*  <--  p2        text

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

FORM f_alv_output USING pt_fieldcat TYPE slis_t_fieldcat_alv

                        pt_events   TYPE slis_t_event

                        ps_layout   TYPE slis_layout_alv

                        pt_iseg     TYPE tt_iseg.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program    = sy-repid

      i_grid_title          = 'Inventory Document Data'(001)

      is_layout             = ps_layout

      it_fieldcat           = pt_fieldcat

      it_events             = pt_events

      i_screen_start_column = 10

      i_screen_start_line   = 10 "20

      i_screen_end_column   = 200

      i_screen_end_line     = 30 "40

    TABLES

      t_outtab              = pt_iseg

    EXCEPTIONS

      program_error         = 1

      OTHERS                = 2.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDFORM.                    " F_ALV_OUTPUT

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

*&      Form  F_USER_COMMAND

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

*       Update the Reason code Comment Data

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

FORM f_user_command USING r_ucomm     LIKE sy-ucomm

                          rs_selfield TYPE slis_selfield..

  IF rs_selfield IS INITIAL.

    CLEAR rs_selfield.

  ENDIF.

  CASE r_ucomm.

    WHEN OTHERS.

      DATA: lrf_grid TYPE REF TO cl_gui_alv_grid.

      IF lrf_grid IS INITIAL.

        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

          IMPORTING

            e_grid = lrf_grid.

      ENDIF.

      IF NOT lrf_grid IS INITIAL.

        CALL METHOD lrf_grid->check_changed_data .

      ENDIF.

  ENDCASE.

ENDFORM.                    "F_USER_COMMAND

 

TOP Include data declaration:

Top include.jpg

 

The hierarchy of Function Group then would be as shown below once development is completed.

 

Function Group.jpg

 

Implicit Enhancement:


Once done with the code to display ALV for entering comments, the FM can be called from appropriate enhancement points.

 

Here the enhancement is placed inside include MM07IFB0 for IM transactions and MM07MFI0 for WM related transactions. These enhancement points are chosen in such a way that all the data required to display in ALV is available.

 

For_IM.png

 

for_WN.jpg

 

Code inside the include as shown below.

 

CONSTANTS: lc_mi07 TYPE sytcode VALUE 'MI07',

           lc_mi10 TYPE sytcode VALUE 'MI10',

           lc_li21 TYPE sytcode VALUE 'LI21'.

 

 

  IF sy-tcode EQ lc_mi07 OR sy-tcode EQ lc_mi10.

    CALL FUNCTION 'ZFSIM_INV_REASON_COMMENT'

      TABLES

        ct_iseg = xiseg.

  ENDIF.

 

 

  IF sy-tcode EQ lc_li21.

    CALL FUNCTION 'ZFSIM_INV_REASON_COMMENT'

      TABLES

        ct_iseg = yiseg.

  ENDIF.

 

As shown, since we are updating SAP internal table XISEG/YISEG, SAP automatically takes care of updating value in standard tables.

 

Append Structure:

 

Shown below is append structure to house comments.

 

Append structure.png

 

Copyright

© Copyright 2013 SAP AG. All rights reserved.

 

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

 

Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER,

OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

 

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

 

Oracle is a registered trademark of Oracle Corporation.

 

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

 

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

 

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

 

Java is a registered trademark of Oracle Corporation. JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and

implemented by Netscape.

 

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

 

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

 

All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

 

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

 



Displayed the Mathematical Operations output in boxes using PIPELINE and ULINE .

$
0
0

ENTER THE T-CODE --> SE38  ,

 

 

ENTER THE PROGRAM NAME AS YOUR WISH ,

 

 

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

*& Report  Z_ASSIGNMENT_DAY21

*&

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

*&

*&

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

 

 

REPORT Z_ASSIGNMENT_DAY21.

 

 

 

 

* Three parameters are created for the standard selection screen.

PARAMETERS: NUMBER1 TYPE p LENGTH 8 DECIMALS 3,

            NUMBER2 LIKE NUMBER1,

            NUMBER3 LIKE NUMBER1.

 

PARAMETERS DISPLAYS THE FIELDS LIKE THIS,

Screenshot1.png

 

 

* Declaration of variables types Integer.

DATA: add_int TYPE p,

      sub_int TYPE p,

      mul_int TYPE p,

      div_int TYPE p,

      rem_int TYPE p.

 

 

add_int = trunc( number1 ) + trunc( number2 ) + trunc( number3 ) .

 

 

sub_int = trunc( number1 ) + trunc( number2 ) - trunc( number3 ) .

 

 

mul_int = trunc( number1 ) * trunc( number2 ) * trunc( number3 ) .

 

 

div_int = trunc( number1 ) + trunc( number2 ) / trunc( number3 ) .

 

 

rem_int = trunc( number1 ) + trunc( number2 ) MOD trunc( number3 ) .

 

 

uline at /(75).

 

 

WRITE:/ '|',3 'ADDITION' CENTERED,15 '|','SUBTRACTION' CENTERED,32 '|','MULTIPLICATION' CENTERED,50 '|','DIVISION' CENTERED,62 '|','REMAINDER' CENTERED,75 '|'.

 

 

uline at /(75).

 

 

WRITE:/ '|',3 add_int CENTERED,15 '|', sub_int CENTERED,32 '|', mul_int CENTERED,50 '|', div_int CENTERED,62 '|', rem_int CENTERED,75 '|'.

 

 

uline at /(75).

 

 

* Declaration of variables type Packed numbers.

DATA: add_dec TYPE p LENGTH 8 DECIMALS 3,

      sub_dec LIKE add_dec,

      mul_dec LIKE add_dec,

      div_dec LIKE add_dec,

      rem_dec LIKE add_dec.

 

 

add_dec = frac( number1 ) + frac( number2 ) + frac( number3 ) .

 

 

sub_dec = frac( number1 ) + frac( number2 ) - frac( number3 ) .

 

 

mul_dec = frac( number1 ) * frac( number2 ) * frac( number3 ) .

 

 

div_dec = frac( number1 ) + frac( number2 ) / frac( number3 ) .

 

 

rem_dec = frac( number1 ) + frac( number2 ) MOD frac( number3 ) .

 

 

uline at /(75).

 

WRITE:/ '|',3 'ADDITION' CENTERED,15 '|','SUBTRACTION' CENTERED,32 '|','MULTIPLICATION' CENTERED,50 '|','DIVISION' CENTERED,62 '|','REMAINDER' CENTERED,75 '|'.

 

uline at /(75).

 

WRITE:/ '|',3 add_dec CENTERED,15 '|', sub_dec CENTERED,32 '|', mul_dec CENTERED,50 '|', div_dec CENTERED,62 '|', rem_dec CENTERED,75 '|'.

 

uline at /(75).

 

 

OUTPUT :

 

 

Screenshot2.png

 

 

Happy Coding,

Vamsi Konaki

SCN Trial Editions: SAP NetWeaver Application Server ABAP 7.4

$
0
0

Latest News

Oct 25, 2013: No country limitation anymore, if you use the direct links below.

Sep 27, 2013: New step-by-step tutorials for setting up your AWS environment.

 

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 which are provided as pre-configured virtual appliances by the SAP Cloud Appliance Library (free of charge). SAP offers this software based on a 90-day trial and evaluation license agreement.

 

Get Your Free Trial As Virtual Appliance

 

The SCN trials of SAP NetWeaver Application Server ABAP 7.4 are 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, log on with your SCN user and hit the Demo Now button. For questions and feedback please post a message in the corresponding ABAP trial thread.

 

tag_cloud_chart_grey_32.png

AS ABAP 7.4 on SAP HANA
[Trial Edition]

tag_cloud_chart_32.png

AS ABAP 7.4 on SAP MaxDB
[Trial Edition]

tag_cloud_chart_grey_32.png

BW 7.4 on SAP MaxDB*
[Trial Edition]

 

*The SAP NetWeaver Business Warehouse 7.4 trial consists of AS ABAP 7.4 and AS Java 7.4 with usage type BI Java as described in the attached solution guide.

 

Try Out These Sample Applications and Tutorials

 

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.

 

BW sample scenarios and demo content (for the BW 7.4 trial)

The SAP NetWeaver Business Warehouse 7.4 trial provides pre-activated sample scenarios for selected OLAP functions and integrated planning and contains predefined objects, such as InfoProviders, Queries and Workbooks. For more information please refer to this page. Moreover, you can execute the Open Items Analytics Dashboard.


Changing Mail Text/ Subject line for Standard Output Types in NACE Transaction

$
0
0

Hi Guys,

 

Below steps helps in understanding about Changing Mail  Text/ Subject line for Standard Output Types in NACE Transaction.

 

 

Changing the Standard Output type Mail Text/Subject Line

  1. Go to NACE Transaction
  2. Select the respective Application as selected below.

3. Then on the top you can see 'Output Types' - select it.

4. In the next screen as shown below - select the respective output type and double click on 'Mail  Title and Texts' under 'Output  Types' in left side under 'Dialog Structure'.

5. In the next screen click on 'EDIT or Change' then 'Mail title and texts' portion turns to edit mode

6. Select the respective language as screen below and then click on 'Text' [Pen/Pencil like Image] - Also if you want to change the Title i.e. Subject - it also can   be changed.

 

7.Then opens a screen where you can maintain the mail text.

8. Save it and it request for a TR# provide it and check executing your process and see if the mail text is changed.

    • By Mohammed Rafi

     

     

    Regards,

    Rafi

    Preparing demo video and calling from 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) Record the video using Cam Studio by simulating user actions to perform the tcode functionalities.

    2) Host the video in a server.

    3) Create a button in the application toolbar to call this video file by passing the server file path to the following function.

          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 a video recorded using Cam Studio software:

     

    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 end-users to know how a tcode works as it can be made available as a help alternative in the tcode itself and also useful for functional guys as they don't have to lift their phones often to teach the end-users .

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

     

    Cheers,

    K.. Arun Prabhu.

    “Be bold when you lose, be calm when you win

    Single Euro Payments Area (SEPA) Implementation of Direct Debit-Technical Design

    $
    0
    0

    Single Euro Payments Area (SEPA) Implementation of DD(Direct Debit)(Technical)

    Sep, 2013

    Introduction

    SEPA stands for ‘Single Euro Payment Area’. It’s a system that is designed to create financial efficiency for countries using the currency Euro by providing a unified system in which to perform financial transactions. The SEPA seeks to create a better system for credit transfers, an improved debit system and a cheaper way for individuals and firms to make transactions within member countries or regions. Implementation of SEPA makes the customers life easier. Irrespective of the national area customers will be able to use the same card for all euro payments and also they need only one bank account in euro area.

    Introduction to SEPA process:

    The below mentioned should be done for Implementation of SEPA business in any SAP system:

    1.    SEPA_Activation_Mandate_Management

    Following are the activities which are to be done as part of this:

    i.        SEPA mandate management has to be activated for the usage with SDD CORE and SDD B2B from FI-AR payment processing.  Apart from activating the SEPA Mandate management we need to maintain the SEPA Mandate management modifiable fields.

     

    Below is the path for activating the SEPA Mandate Management and maintain the modifiable fields.

    IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> General Settings.

    screen1.png

    IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> Define Modifiable Fields

    screen2.png                                                                                                                                                                  

    ii.        Creation of new DMEE Payment Format tree for SEPA credit transfer and SEPA direct debit.

    ·         SEPA_CT and SEPA_DD are the DMEE formats provided by SAP.

    ·         As we will be dealing with multiple countries it is always better to copy the DMEE formats and create new ones. If there is any custom requirement for any country create a user exit and assign to the field that needs to be changed dynamically.

    2.  Pre Notification with payment run  :

    With a direct debit pre-notification, Markets can inform a payer in writing in advance of the debiting of his account. To do this, one has to schedule a run for the creation of direct debit pre-notifications before the payment run, meaning before clearing the open items and creation of payment media. These correspond in structure to the payment advice notes, and therefore contain details of the run date, the amount to be collected, mandate ID, Unified Creditor Identifier etc.

    Following are the SAP notes to be implemented for SEPA Pre-notification.

    SAP Note

    Description

    1679118

    F110:  Custom Selection for Batch Input

    1760564

    F110S:  Selection Check for Customers and Vendors

    1770425

    F111/SEPA: Mandate rejected as invalid after change

    1771071

    FBCJ : Reversal possible despite cleared item

    1776076

    F110/F111 : BADI for SEPA Mandate usage

    1780941

    SEPA: Direct debit Pre-Notification

    1792691

    Valid SEPA mandate is not found in the system during payment proposal processing

     

    As part of the Note implementation 1780941, we need to implement manual steps given below for importing the Standard SAP Form.

    ·    SAP has provided text file by using this file we need to import the object F110_DD_PRENOTIF into SAP by executing program RSTXCRP.  This is standard SAP form which will be used for sending PreNotifications.

    ·    SAP has provided XML file by using this file we need to import the object F110_DD_PRENOTIF into SAP using SFP transaction code. Once it is uploaded, activate the form.

    Once all the relevant OSS Notes are implemented for SEPA Direct debit pre-notification, we will get option of checkbox for Pre-notification in F110 transaction and also pre-notification relevant standard program RFFOAVIS_DD_PRENOTIF and script form (F110_DD_PRENOTIF) available in the system.

    screen3.png

    The above check box is checked if we need to do SEPA prenotification.

    screen4.png

     

    RFFOAVIS_DD_PRENOTIF: This is the payment advice print program that is used to print the pre-notifications the pre-notification

    F110_DD_PRENOTIF: This is the standard SAP script which is used to send the pre-notifications.

    scrren61.png

              Based on the user requirement, the form name can be changed

    ·      The new "direct debit pre-notification" object is visible in the payment run (F110), in the document display (FB03), in the line item display (FBL5N) and in mandate display (FSEPA_M4). It can be deleted again if the direct debit pre-notification customer objects to it (for example, because the customer pays the bill himself). Otherwise, the posting run and the payment medium creation are performed after the end of the specified wait time based on the direct debit pre-notifications.

    3.  Creation of SEPA Mandates for payment transactions :

    ·       Before doing any transaction for any SEPA customer we need to have a mandate create for the Customer.

    ·       Before creating a mandate the Customer Should have IBAN number.

    ·       Transactions used :

    Creation

    FSEPA_M1

    Change

    FSEPA_M2

    Display

    FSEPA_M3,FSEPA_M4

    NOTE: Mandates can also be created from the payment tab of the Customer Master XD01, FD01, XD02,FD02.

    NOTE: Mandate Number can be either External or Internal Number.

    ·       To make our work easier technically we can use the below procedure using the below BAPI's:

    ·       The table that is Master for all the SEPA mandates is SEPA_MANDATE.

    ·       SEPA_MANDATE: This is the Standard Smart form used to print the mandate details for any customer.

    ·       Assume a file with the Customer and mandate Information is available

    Ø  Check if the customer is created by checking in the KNB1 table.

    Ø  If the Customer is present then check if the Customer has IBAN and BIC number.

    Ø  Check if the mandate is not created for Customer with the mandate number using the BAPI SEPA_MANDATES_API_GET.

    Ø  For the BAPI SEPA_MANDATES_API_GET pass the customer number in the importing parameter to check if there is any mandate information present for the Customer SEPA_GET_CRITERIA_MANDATE-snd_id = Customer Number .

    screen6.png

    Ø  ET_MANDATES contains the mandate information that is fetched from BAPI based on the Customer Number.

    scrren71.png

    NOTE :   SEPA_MANDATES_API_GET FM cannot be used for multiple mandate scenario. We can write take MGUID from REGUH table and go to SEPA_MANDATE table and get the IBAN number and mandate number.

     

    Three BAPI'S are majorly used to Creation and updating of the mandate details of the Customer.

    To fetch the Mandate information for a particular Customer from the table SEPA_MANDATE table

    SEPA_MANDATES_API_GET

    Create the Mandate for a Customer

    BAPI_SEPA_MANDATE_CREATE1

    Modification of Mandate details for a customer

    BAPI_SEPA_MANDATE_CHANGE1

     

    ·       Mandate Creation:

    Ø Use the BAPI BAPI_SEPA_MANDATE_CREATE1 to create the mandate .

    Ø BAPI_S_SEPA_MANDATE_COMMON structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details ) and  receiver details (Company code data ).

    screen-8.png

    Ø Then collect all the address information either from the file provided or from the customer master data and fill the Sender information in the structure BAPI_S_SEPA_MANDATE_COMMON.

    Ø Then based on the company code fetch the address details of the Company code and fill the Receiver information in the structure BAPI_S_SEPA_MANDATE_COMMON.

    Ø ES_MANDATE_CREATED exporting parameter in the above BAPI gives a success message if the mandates are correctly created for the customer.

    Ø  Error handling can be done with the return exporting parameter.

    screen9.png

     

    ·       If the mandate already exists then check if there is any change in the mandate information.

    Mandate modification:

    Ø  Use the BAPI BAPI_SEPA_MANDATE_CHANGE1 to change the already existing mandate.

    Ø  BAPI_S_SEPA_MANDATE_CHANGE structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details) and  receiver details (Company code data ).

    screen9.png

    Ø  In case ofupdation is failed it can handled by  return parameter of the BAPI

    screen-10.png

      Display of Mandates :

    Ø  The created mandates can be checked by FSEPA_M3 Give the Mandate number or Customer Number and check for the Mandate information.

    screen11.png

    On Click on Enter the below Screen appears which displays all the information.

    screen12.png

     

    Ø We can also check the Mandate information through Customer master display  using transaction fd02,xd02,xd03,fd03.screen13.png

    Click on the Tab to check and create the mandate Details from Customer master

    Display the List of Mandates:

    Ø  Use the transaction FSEPA_M4 to display a list for customers for a particular company code.

    screen14.png

    Ø  Mention the company code in the below transaction and then execute all the mandates present for the company code will be displayed.

    Ø  A list of mandates will be displayed as shown in the below screen shot.

    screen15.png

    The above lights depicts different status of the mandates below are the differnent status of mandates.

    0         

    Entered

    1

    Active

    2

    To Be Confirmed

    3

    Locked

    4

    Canceled

    5

    Obsolete

    6

    CompletedCompleted

    Ø  If we need to print a particular mandate information then select the Print mandate button on the top right corner of the list .

    screen16.png

    Ø  For this SAP has provided a smartform SEPA_MANDATE.This can be customized at central level and the thus the mandate can be created and mandate information can be printed.

    screen17.png

    All the inforamtion related to the mandate is available in the table SEPA_MANDATE.

    SAP note 1906078 - FTW1A: BADI for additional selections from BKPF - implementation

    $
    0
    0

    This document has as purpose to help anyone facing issues implementing note 1906078 (step 3)

    Note 1906078 is a pre-requisite for note 1923322, but after step 3, you need to stop and implement note 1923322 and then come back again to your manual tasks.

     

    Step 1: The report ZFTW1A_BADI_IMPLEMENTATION is provided under 'Attachements' tab. Copy and execute this report.      

    Step 2: implement the note via snote

    Step 3: Goto transaction SE18 and enter BADI name as BADI_TXW_DATA_SELECTION_QUERY. Create BADI Implementation EXTRACT_TXW_FI_POS with Enhancement Implementation ZTXW_FI_POS, implementing class ZCL_TXW_SELECT and with Description 'Additional fields to be filled in customer include'.


    here are the screen shots

    snap1318.png


    snap1319.pngsnap1320.png

    Here I changed the name of my class as it was not getting created for some unknown reasons)

    snap1321.png


    snap1323.pngsnap1324.png

    Step 4: The document BADI_Implementation_Code gives the code to be implemented for each of the methods. Activate the methods after implementation of the note 1923322.


    You need to implement note 1923322 here.

    double click on the class ZCL... and update the private section with the codes provided in note attachment

    snap1325.png


     

    snap1327.png


    Paste the   methods in the implementation section and take note that in the second method, the first line 'method <method name> is missing.


    snap1328.png


    For step 5 and step 6, follow the instructions in the note and you will probably require an access key .


    Hope it helps.


    The look of your methods change by clicking on the following buttons:

    snap1329.pngsnap1330.png



    I would like to thankJann Willms  and andrea montella for their help when I was getting lots of problem to implement the notes:

    The following threads can also be useful.

    Re: SAP note 1906078 - FTW1A: BADI for additional selections from BKPF - implementation issue

    FTW1A: BADI for additional selections from BKPF

    How to call a dll file of windows using SAP ABAP

    $
    0
    0

    In ABAP language exists many forms to connect and i want explain how to call dll files for Windows

    Below follow step by step to construction:

     

    1 – Create the dll files. In my example i am using the visual basic language, but you can use another language of programmer (ex.: Delphi, C# etc)

     

    VERSION 1.0 CLASS  
    BEGIN    MultiUse = -1  'True    Persistable = 0  'NotPersistable    DataBindingBehavior = 0  'vbNone    DataSourceBehavior  = 0  'vbNone    MTSTransactionMode  = 0  'NotAnMTSObject  
    END  
    Attribute VB_Name = "DLL_VB"  
    Attribute VB_GlobalNameSpace = False  
    Attribute VB_Creatable = True  
    Attribute VB_PredeclaredId = False  
    Attribute VB_Exposed = True  
    ' Declaration of variable return
    Private s_retorno As String  
    Public Property Get retorno() As String        retorno = "retorno: " & s_retorno  
    End Property  
    ' Function that receives the command and variable playing in s_retorno
    Public Function envia_comando(ByRef s_comando As String)      s_retorno = s_comando  
    End Function  

     

    1.1 - Afterbuilding the DLLyou need to registerin windows using the command:

     

                    regsvr32 <name file>.dll

     

      After this you are should look the pop-up with message:


     

    2 - Execute the program regedit.exe in Windows System and find the name of DLL file


     

    You need find two values in regedit.exe.

    CLsid : {2EC47E73-2E05-45BA-AC8B-CD7E798D4034}

     

     

    TypeLib: {4F4B5B12-5F45-43DB-A06E-2065395F9866}

     

     

    3 - This values do you must put in transaction SOLE

     

     

    4 - Below the example in SAP ABAP that call dll file in Windows.

     

    This example: send a string and return another string using the file dll

     

    *"----------------------------------------------------------------------
    *"*"Interface local:
    *"  IMPORTING
    *" VALUE(I_COMANDO) TYPE  CHAR20 OPTIONAL
    *"  EXPORTING
    *" VALUE(E_RETORNO) TYPE  CHAR20
    *"  EXCEPTIONS
    *" CREATE_OBJECT_ERROR
    *" GET_PROPR_ERROR
    *"      CALL_ERROR
    *" FREE_OBJ_ERROR
    *"----------------------------------------------------------------------
    * Includes  INCLUDE ole2incl.
    * Global Variables  DATA: obj_vb TYPE ole2_object,        vg_comando(20) TYPE c,        vg_retorno(20) TYPE c.
    * sends the command to the dll  vg_comando = I_COMANDO.
    * Creating the object to use the DLL  CREATE OBJECT obj_vb 'TESTDLL'.  IF sy-subrc NE 0.    RAISE create_object_error.  ENDIF.
    * Sending the command to the dll  CALL METHOD OF obj_vb 'envia_comando' EXPORTING #1 = vg_comando.
    * Receiving command of dll  get property of obj_vb 'RETORNO' = vg_retorno.  IF sy-subrc NE 0.    RAISE get_propr_error.  ELSE.    E_RETORNO = vg_retorno.  ENDIF.
    * Deallocates the object memory  FREE OBJECT obj_vb.  IF sy-subrc NE 0.    RAISE free_obj_error.  ENDIF.
    
    ENDFUNCTION.

     

    I have helped, any questions please send a message.

     

    Regards

     

    Marcelo Macedo

    ABAP Programming Best Practices

    $
    0
    0

    ABAP Programming Best Practices

     

    Contents

    Introduction

    Top 10 Rules

    Maintainability Rules

    Stability Rules


    1.     Introduction

     

     

                   This document is intended to cover the basics of good ABAP programming for ABAP developers and ABAP learners. In a normal SAP environment we use ABAP to write a code for doing a look-up in transformation or to code function modules to extract data from source systems. This process would generally involve declarations, selection of data, read the selected data to manipulate it or to perform calculations. I have taken into consideration only these basic steps for this document.

     

    2.     Top 10 Rules

     

         Rule 1: Use the Code Inspector (CI), the Extended Syntax Check (if code inspector is not available) or ABAP Test Cockpit (ATC) and fix all errors and warnings – respectively P1 and P2 for ATC.

        

         Rule 2: Use the TRY / ENDTRY instead of CATCH / ENDCATCH statement to trap runtime errors and handle them.

        

         Rule 3: Always handle all exceptions of a function module or method call. If the function module/method actually issues messages, handle the exceptions with the default message statement. Otherwise handle them with your own error messages.


          Rule 4: Always check for the deletion flag on key master data tables. LOEVM, LOEKZ, LVORM, etc are some of the Deletion flags.


          Rule 5: Check the return code after every statement that updates it. Check with SY-SUBRC only.

     

          Rule 6: Internal tables must be defined with the appropriate table type based on usage (HASHED, SORTED or STANDARD).


          Rule 7: When using the FOR ALL ENTRIES option in an SQL WHERE clause, you must ensure that the internal table used in the FOR ALL ENTRIES option is not empty, immediately before the SQL statement.

     

          Rule 8: Alway apply lock to a tables before issuing update commands.


          Rule 9: Use Join conditions instead of SELECT....INTO itab with subsequent SELECT.....FOR ALL ENTRIES IN itab, except for buffered tables.


          Rule 10: Don't use INSERT, UPDATE, etc. within loops.


    3.     Maintainability Rules

                             The Maintainability Rules are available in the following document: ABAP Programming Best Practices: Part-II

    4.     Stability Rules

                             The Stability Rules are available in the following document: ABAP Programming Best Practices: Part-III

     

     

    Note: I will keep updating this document based on further corrections/suggestions.


    ABAP Programming Best Practices: Part-III

    $
    0
    0

    ABAP Programming Best Practices: Stability

     

    Contents

    Introduction

    Stability Rules


    1.     Introduction

     

     

                   This document is a continuation of 'ABAP Programming Best Practices' which is intended to cover the basic Stability rules of good ABAP programming for ABAP developers and ABAP learners. In a normal SAP environment we use ABAP to write a code for doing a look-up in transformation or to code function modules to extract data from source systems. This process would generally involve declarations, selection of data, read the selected data to manipulate it or to perform calculations. I have taken into consideration only these basic steps for this document.

     

    2.     Stability Rules


              Rule 1(Important): It is always recommended to include proper error handling to avoid abnormal terminations by the means of checking SY-SUBRC value after every statement that changes it and if you are not doing anything then just explain why not with a proper commenting.


              Rule 2: It is good to validate all the fields on the selection screen. If no condition is specified then validate them according to the forigen key definations persent in the DDIC.


              Rule 3(Important): It is always recommended to sort the standard table(If used) before using BINARY SEARCH with that table.


              Rule 4: It is good practice not to include TIMESTAMP field with COLLECT Statement.


              Rule 5: Always ensure that the DELETE ADJACENT DUPLICATES is applied to sorted internal tables.


              Rule 6: Never try to use CLIENT SPECIFIED addition to read or update data from another client within the system until and unless it is very necessary.


              Rule 7: It is always recommended to read the time dependent data with appropriate time restrictions.


              Rule 8: It is always good to use DEQUEUE ALL to remove system lock when the SYSTEM_FAILURE (SF) exception is raised from the ENQUEUE FM.


               Rule 9: It is always recommended to have correct defination of reference table and reference field for the currency and amount fields in order to display correct ouptut.


              Rule 10: It is always recommended to create a text table for the language specific elements present in the table, and the proper link between the element and the text table has to be maintained.




    Note: I will keep updating this document based on further corrections/suggestions.


    Creation of Extended IDOC

    $
    0
    0

    Purpose:

    The extension IDOC concept comes into action when the standard IDOCs provided by SAP do not meet the customers’ requirement. IDOC is the acronym of Intermediate Document; IDOCs are nothing but a Data Format provided by SAP to transfer data in and out of an SAP system. Data are grouped under this (IDOC) data format for each application in order to maintain consistency while transferring data from one system to another system. Hence each application like order, delivery, invoice etc will have a standard IDOC available along with standard processing programs for the same. When standard IDOC does not meet customer’s requirement, custom extension IDOC are developed to meet the requirement and the corresponding processing program will be enhanced using existing customer exits.

    The purpose of the document is to provide the step by step procedure for creating an extension IDOC.

     

    Scenario:

    In this document, we will discuss the extension of basic IDOC type “DELVRY03‟, this IDOC type is used to group delivery detail. The mentioned IDOC type does not have fields VBUK-KOSTK (Overall picking) and VBUK-KOQUK (Status of pick confirmation in its standard format. But customers business needs demand these fields to be added to delivery details. Hence the basic IDOC type “DELVRY03‟ will be extended as “ZDELVRY03‟ with the two new fields and relevant processing program will be identified and processing logic for the new fields will be included in the relevant customer exits.


    Steps To Be Followed:


    1) Create a Custom segmentTCODE WE31


    It begins with creating a custom segment; type your custom segment name as ZELDP1 and click on the create button as shown below.

    ZELDP1.png


    When the create button is clicked, the below shown screen will be displayed. Enter a short description for the custom segment and add the required field name and the corresponding data element. Once the required fields are added, click on the save button.


    Capture.PNG

    After clicking on save button, click on back button, you will see the below show screen. Now click on the segment definition you have created and do Set Release from EDIT menu.


    1.png


    Here we can see that the release check box is checked.


    Without releasing your segment definition you cannot use the segment in any IDOC type.


    With this, custom segment creation is completed.


    2) Create an Extension IDOC- TCODE WE30


    With the above created custom segment, enter a name “ZDELVRY03‟ for the extension IDOC and select on the Extension radio button and click create button.

    Click on the icon to create extension IDOC.


    2.png


    The following popup screen will be displayed. Click on the “Create New‟ radio button to create an extension with the help of a Basic IDOC type. Enter the standard basic type name “delvry03‟ in the “Linked Basic type‟ field and enter a short description and continue.


    3.PNG

    Note: Use the options –


    • Create New: Create the extension without a reference.
    • Create copy-here the extension can later be changed if necessary
    • Create as successor: Note that only one successor is allowed per release for each extension.

     

    The following screen will be displayed with all the standard segment of basic type “delvry03‟. Now we need to add our custom segment to the required segment, in our example we will take segment E1EDL22. We will have to add the custom segment ZELDP1 to segment ELEDL22.


    4.png


    Click on the segment E1EDL22 to select it.


    Select the segment E1EDL22 and click on the create button, an information message will pop up and say Extension segment type(s) will be in child segment type(s) of E1EDL22‟ as shown below. Click on continue.

    5.png


    Another pop up will be prompted for entering the custom segment name and attributes. Enter the name of the segment ZELDP1, minimum and maximum occurs as shown below.


    6.png

    The attributes entered here are chosen as per the requirement, when a custom segment is assigned at item level the minimum and maximum number is chosen considering the frequency the segment can occur in the idoc.


    Newly added segment is seen as below.


    7.png

    Save the extension IDOC and click on the back button and go to utilities -> Enhancement -> Assign basic type.


    The below pop up will be prompted with the basic type name, which we have used to create our extension type.in our case it is “delvry03” .Click on the continue button.

    8.png

    Now click on the Set Release menu item in EDIT menu to release the extension IDOC.

    A pop up will be prompted as shown below and click Yes to release the Extension IDOC.


    9.png

    We have successfully created the extension IDOC.


    3) Create a logical Message Type – TCODE WE81

    By default the screen will be in display mode, go to change mode to enter a new entry. Give some name to the logical message type and a short description. Save the entry.


    11.png

    4) Assign Logical Message Type to Extension IDOC Type –TCODE WE82

    Assign the created extension IDOC type with the above created logical message type. Here you will assign the message type with the extension IDOC type along with the basic type and release version combination as shown below.

    Save the entry. Now the message type “ZDELVRY‟ will have the same structure as extension IDOC “ZDELVRY03‟ in runtime.

    12.png


    5) Create a Partner Profile and Assign Message Type – TCODE WE20

    Create a partner profile and assign our message type to it. Also provide details like output types in the tabs.

    Click on the Create Outbound Parameter button (An icon with green plus symbol). Following screen will be displayed. Enter the following information.


    13.png

    Transfer IDOC immediately option is selected to send the IDOC immediately when a delivery document is saved (i.e. each time the delivery document is saved successfully the IDOC will get created and transferred to the port.


    6) Finding the Customer Exit and Write the Logic to Populate the Custom Segment


    Find the function module. In this case it is the idoc_output_delvry.

    Next step is to find the customer exit in the function module to populate the custom segment in the extension IDOC. Check for the PERFORM that fill the Data records internal table and proceed to find the relevant customer exit or directly you can search customer exit for Data record. Usually the customer exits for Data records will be “customer-function “002”.

    7.png

    7.png

    This is the internal table idoc_data that need to be populated to add the new segment‟ZELDP1‟ and the corresponding fields.

    Now check the attributes tab to see the package details of this function module

    14.png

    Go to transaction SMOD and press F4 on enhancement option.

    In the pop up select the information system and enter the package name found above in the package option.


    15.png

    Now a pop up appears that lists the exit names here we will select the exit name whose short text matches our requirement.

    7.png

    Here we will select the exit name V55K0002 as it matches our requirement.

    Now select the radio button Components and press enter.

    16.png

    On selection, we get the pop up that shows the function module exits. Double click on the exit.

    17.png

    Upon double clicking the module, we get the necessary include where we will write the code.

    18.png

    Double click on include name, it is this include which has the custom code for the Data Records.

    The below code has the logic for adding the custom segment “ZELDP1‟ as child of “E1EDL22‟ in the data record internal table “IDOC_DATA‟ and what data needs to be populated in the fields of the custom segment.

    19.png

    Save and activate include ZXTRKU04.

    Note: The code written above will be executed only if this enhancement components Project is activated in SMOD.


    20.png

    7.png

    Here we can see that the implementation is checked. If the project is in the deactivate mode then the code will not work.

    With this the Extension IDOC is successfully created. 


     

    1)

    ABAP Programming Best Practices: Part-II

    $
    0
    0

    ABAP Programming Best Practices: Maintainability

     

    Contents

    Introduction

    Maintainability Rules


    1.     Introduction

     

     

                   This document is a continuation of 'ABAP Programming Best Practices' which is intended to cover the basic Maintainability rules of good ABAP programming for ABAP developers and ABAP learners. In a normal SAP environment we use ABAP to write a code for doing a look-up in transformation or to code function modules to extract data from source systems. This process would generally involve declarations, selection of data, read the selected data to manipulate it or to perform calculations. I have taken into consideration only these basic steps for this document.

     

    2.     Maintainability Rules


              Rule 1:The Programs which are copied from the Standard program must have the reference to the cloned program.


              Rule 2: The Programs or the Routines that are called from the specific locations including User Exits, The documentation must be maintained which indicates the calling program or routine.


              Rule 3: It is always recommended to use Data Dictonary Names for field texts on screen where ever applicable.


              Rule 4: Always try to put Repetitive code into some Modularisation unit which must take into account the re-usablity and which should be kept short as possible.


              Rule 5: Always try to keep the Main Program short as possible. And try to work with re-usable, structured and small Methods.


              Rule 6: It is always recommended not to access the global variables in any object, instead always try to pass actual parameters via the object interface or signature.


              Rule 7(Important): It is always recommended to pass internal tables via USING or CHANGING addition of the FORM or PERFORM statements instead of TABLES addition.

     

           Rule 9:It is always good not to use TABLES section while defining new function module instead it is recommended to use DDIC table types as Importing, Exporting and Changing Parameters except for transmitting large amount of data.

              Rule 10(Important): It is always recommended to encapsulate gloabl data in TOP-Include. The name of this include should be same as program name with suffix as '_TOP'.




    Note: I will keep updating this document based on further corrections/suggestions.

    Creation and Consumption of Web Services

    $
    0
    0

    1 Purpose

    A Web service is a modularized, executable unit. It can be called in heterogeneous system landscapes and is not restricted to a single host system. Each output is determined based on the given input parameters. This output is then passed back to the caller. Web service is a software system designed to support interoperablemachine-to-machine interaction over a network

    For example, Web services can serve to perform a credit card check, convert a currency amount, send a price query to a provider, or simply to place an order. Also, industrial manufacturers can provide their customers, partners, and suppliers with Web services for implementation in their own programs in order to set up cross-system supply chain solutions.

    This document will discuss two parts of a Web Service –

            1.     Consuming a web service

            2.     Creating a Web Service in SAP


    2 Consuming a Web Service

         To consume a Web service, we need to create the following:

             a.    Create proxy for the Web service in the ABAP Workbench using a WSDL document as a basis.

             b.    Then create a logical port to define the runtime features of the Web service client proxy. (This will be created by BASIS hence we will not be discussing it in this document)

            c.    Then to call the web service, create an ABAP program to provide input and get output.


         2.1 To Create a Proxy

               1. Go to Transaction SE80 -> Edit Object -> Enterprise services -> Create

                             1.png


                   2. Select External WSDL -> Continue

                        2.png

                   3. Select Local File -> Continue.

                                  3.png

              4. Input a location -> Continue -> ZES_ (Prefix) -> Continue

                                  4.png

                 5. The creation of Proxy is Completed and Save and Activate, and Proxy is created.

                             5.png

           

          2.2 Create a Logical Port

                   NA for SAP ABAP Development.


            

          2.3 Program to call the Web Service

                   1.      The structure of the proxy is :

                                  6.png

                            

                        2.     Only Constructor and Retrieve methods can be called in the program to use the Web service.

     

                        3.     Create References to Proxy class of ZES_XXXXXX

              1. Data – LO_TIME TYPE REF TO ZES_XXXXXX

     

                        4.     Create References to Input structure of Retrieve class

     

                        5.     Create References to Output structure of Retrieve Class

     

                        6.     Create object for proxy class reference created in step 3

                 

                        7.     Assign values to the input structure created to be used in the Retrieve class

     

                        8.     Call RETRIEVE method of proxy class and provide input and output structures. 


    3.         Creating a Web Service

        1. Create a FM, say ‘YFM_CREATE_WEB_SERVICE_TEST’ which is RFC Enabled.
        2. Go to Utilities -> More Utilities -> Create Web Service -> From the Function Module

                             7.png

                        3.    Enter Web Service name and Description, and Continue.

                             8.png

                   4.   Check Map Name -> Continue

            If the checkbox Name Mapping is ticked, the wizard accepts the existing names for the end point          9.png

    5.   Choose approriate input -> Continue .

    10.png

    6.     Tick Local object ->Continue

    11.png

    7.     Click on Complete.

    12.png

    8.     The Web Service has been created and now activate it.

    13.png

    9.     Now, to test the Web Service

                          Press F8 -> Choose Generate Request Template -> Execute -> Execute the Request -> Output Successfully recieved

                        14.png

                         15.png

                             Call Successful:

                             15.png

     

        

    Insert Data Via BAPI Using Excel-VBs

    $
    0
    0

    Hi,

     

    Many of us know how to access RFC / BAPI and read data from SAP server;

    today I am going to show you how to save data into Z table Via RFC/BAPI.

    Here I assume that you know how to create BAPI from RFC Function module, here we go.

     

    Steps Involve.

    • Create Z table for data save   [Quick View]
    • Create BAPI Structure for Data type [Quick View]
    • Create RFC function module [Quick View]
    • Create BAPI from function module [Quick View]
    • Write VB script into MS-Excel [Detail View]

     

    1. Create Z table for data save

     

     

     

         2.  Create BAPI Structure for Data Type

     

     

    This will be used to declare import parameter in RFC function module

     

     

        3.Create RFC function module

     

     

     

     

     

     

     

     

     

         4.     Create BAPI from function module

     

     

    1. Writing a VB-Script Detail Explanation.

     

                   A.Declare Variable

     

    Dim Destination_System As Integer

    Dim objBAPIControl As Object 'Function Control (Collective object)

    Dim sapConnection As Object 'Connection object

    Set objBAPIControl = CreateObject("SAP.Functions")

    Set sapConnection = objBAPIControl.Connection

    Dim valu As String

     

                    B. Connection Parameters

     

                                  sapConnection.client = "client number"

                                  sapConnection.user = "User name"

                                  sapConnection.Language = "E"

                                  sapConnection.hostname = "ip address server"

                                  sapConnection.Password = "passwird"

                                  sapConnection.SystemNumber = "System number"

                                  sapConnection.System = "system id"

     

    you can get above parameters from SAP Logon properties.

     

     

                   C.  Determine Connection is establish or not.

     

    If sapConnection.logon(1, True) <> True Then

    MsgBox "No connection to R/3!"

    Exit Sub 'End program

    End If

     

                   D.  If connection is successful then perform the save operation.

     

    Set objUserList = objBAPIControl.Add("ZBAPI_TESTSAVE")

    Worksheets(1).Select

     

    For i = 1 To 5

    valu = ActiveSheet.Cells(i, 2)

                                        objUserList.exports("NAME1") = valu

    returnFunc = objUserList.Call

                                       ActiveSheet.Cells(i, 2) = ""

    Next i

    MsgBox "Record(s) saved", vbInformation

     

    • First line is to assign function module name as object.
    • second line is to select Excel sheet number
    • Third line to begin loop up to 5 times ( i am going to save 5 names at once)
    • Forth line it so select cells dynamically ActiveSheet.Cells(Row,Column) -

            every time i increment and row changes columns remains static as we have fixed it to 2.

    • Fifth line is to export cell value to RFC function parameter (it will transfer data excel to rfc function parameter)
    • Sixth line is to call / Execute function (Actual execution done and data transferred physically)
    • Seventh line is to clear cell by Row and column
    • eight line is to Return the loop and starts from the beginning until condition fails (that is 5 times)

     

     

    Excel Sheet Preview.

     

     

    *All the operation is done under

     

    Sub Button1_Click()

     

    ***Above Code***

     

    End Sub

     

    You can also upload data to standard table just apply your logic and things will be done.

     

    -Avirat.

    How to create customer screen on ME21N/ME22N/ME23N Item Level using BadI

    $
    0
    0

    How to create customer screen on ME21N/ME22N/ME23N Item Level using BadI


    This is manual how to use the BadIs ME_GUI_PO_CUST and ME_PROCESS_PO_CUST to create a cusstomer screen on item level in ME21/22/23n. And how to fill this screen with a customer field.

     

    Needed Badis: 

    • ME_GUI_PO_CUST (classical)
    • ME_PROCESS_PO_CUST (enhancement spot)


    Helpful information and sample code in example implementation class CL_EXM_IM_ME_GUI_PO_CUST and CL_EXM_IM_ME_PROCESS_PO_CUST. In both examples all needed information is metioned, but not always easy to find!


    SAP Notes: 1910516


    Step by step:


    1.      Append CI_EKPODB with your customer field


    2.      Create with SE11 a table with the following fields


              a.      MANDT

     

              b.      EBELN

     

              c.      EBEKO

     

              d.      Your customer field:


     

    3.      Create with SE11 a structure with the following fields

     

              a.      Your customer field


     

    4.      Create with screen painter (SE51) a screen with the new field

     

              a.      Program should be either your already existing function pool for MM exits or create a copy of the SAP example SAPLMEPOBADIEX

     


     

              b.      Attributes



              c.      Element List (referring to your structure fields)!

     


              d.      Flow Logic

     

                    i.      Important to add the two modules event_pbo and module_pai!


     

    5.      Change the function pool for global data in the top include

     

              a.      Tables: your structure of step 3

     

              b.      Internal tables both referring to your table of step 2

     

              c.      Include lmeviewsf01 (otherwise you will get a dump!!)


     

    6.      Create the following function modules in the same function pool you used in the layout!

     

              a.      Y_MM_MEPOBADI_GET_DATA as copy of example code MEPOBADIEX_GET_DATA

     

                        i.      Import Parameter

     

                            1.      IM_EBELN type EBELN

                            2.      IM_EBELP type EBELP



                        ii.      Export parameter

     

                            1.      EX_DATA type your table of step 2



                        iii.      Source code completely identically to MEPOBADIEX_GET_DATA


     

    b.      Function module Y_MM_MEPOBADI_PUSH as copy of MEPOBADIEX_PUSH

     

                        i.      Import Parameter

     

                            1.      IM_DYNP_DATA type your structure of step 3


     

                        ii.      Source code: fill your structure with the import parameter


     

    c.      Function module Y_MM_MEPOBADI_POP as copy of MEPOBADIEX_POP

     

                        i.      Export Parameter

     

                            1.      EX_DYNP_DATA type your structure of step 3

     

     

                        ii.      Source code: fill export parameter with your structure

     

     

    d.      Y_MM_MEPOBADI_SET_DATA as copy of example code MEPOBADIEX_SET_DATA

     

                        i.      Import Parameter:

                    

                            1.      IM_DATA type your table of step 2

                            2.      IM_PHYSICAL_DELETE_REQUEST type MMPUR_BOOL

     


                        ii.      Source code:

     

                            1.      Important to change the in line your customer field:

     

                                      * update existing data

                                        <data>-yyrevisionstand = im_data-yyrevisionstand.

     

    7.      BADI (SE18)

     

    a.      ME_GUI_PO_CUST

     

                        i.      Go to Menu --> Implementation --> Overview and choose your implementation

                      ii.      If there is no implementation you have to create one (search in scn how to do)

     

    b.      Change Class Interface YCL_IM_MM_ME_GUI_PO_CUST

     

                        i.      Attribute:

                            1.      SUBSCREEN1 / Level: Constant / Visibility: Public / Type: MEPO_NAME / Initial Value ‘ITEMSCREEN1’

                            2.      DYNP_DATA_PBO / Level Instance Attribute / Visibility Private / Associated Type your structure of step 3

                            3.      DYNP_DATA_PAI / Level Instance Attribute / Visibility Private / Associated Type your structure of step 3


    c.      Method:

     

                        i.      SUBSCRIBER: enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~SUBSCRIBE


                            1.      Method SUBSRIBE it mandatory to show your own tab.

                            2.      According to Note 1910516 it is not possible to show more than one customer tab (one in header, one in position). I did not test if this                                  is still true


     

                            Important:

     

                            ls_subscriber-name = defined attribute

     

                            ls_subscriber-dynpro = dynpro number of your SE51 screen of step 4

     

                            ls_subscriber-program = function pool of your SE51 screen of step 4

     

                            ls_subscriber-struct_name = your structure of step 3

     

                            ls_subscriber-label = either direct text of via text definition of your class

     

                            ls_subscriber-position = position of the tab in the position details. According to Note 1910516 it should be between 30 and 50 to avoid                                                            problems with existing screens.

     

                        ii.      MAP_DYNPRO_FIELDS: : enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~MAP_DYNPRO_FIELDS

     

                            1.      Change source code by entering your field in the when case in line 56

                            2.      Important: mapping one of the following customer fields in Line 58

     

     

     

     

                        iii.      TRANSPORT_FROM_MODEL enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_FROM_MODEL

     

                            1.      Important: Change function module to your module of step 6a

     

     

                        iv.      TRANSPORT_TO_DYNP enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_TO_DYNP

     

                            1.      Change function module to your module of step 6b



                        v.      TRANSPORT_FROM_DYNP enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_FROM_DYNP

                  

                              1.      Change function module with your module of step 6c

     

     

                        vi.      TRANSPORT_TO_MODEL enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_TO_MODEL

     

                            1.      Delete lines for standard fields (line20 – 32 of the example coding are not necessary for custom fields)

                            2.      Change “if case” of line 64 to your own field

                            3.      Change function module of line 66 to your module of step 6a

                            4.      Change line 73 to your own field

                            5.      Change function module of line 74 to your module of step 6d

                            6.      Enter line 78 (move changed value to local structure)

                            7.      Enter call of method set_data


     

    8.      BADI Enhancement Spot ME_PROCESS_PO_CUST

    Have a look into CL_EXM_IM_ME_PROCESS_PO_CUST to get sample coding



    Important: you can call only one Enhancement Implementation, if there is already an active implementation you have to either use this or deactivate it!


     

    a.      Method IF_EX_ME_PROCESS_PO_CUST~FIELDSELECTION_ITEM

     

                        i.      Necessary to display your customer field (compare to Note 1910516)


     

                            1.      Enter the following coding:

                                      Important: Change line 45 to your customer field used in Method MAP_DYNPRO_FIELDS


     

    b.      Method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM

     

                        i.      Necessary to pre-fill you customer field with e.g values from material master

     

                        ii.      Enter e.g. some lines like below:

                        iii.      Important is to use the following lines to get the entered data

     

                                  call method im_item->get_data

                                  receiving

                                re_data = lwa_mepoitem.


     

    iv.      And after your select to use the following lines to set your selected data

                                call method im_item->set_data

                                exporting

                                im_data = lwa_mepoitem.



     

    If you just followed all steps and also put all function modules into the same function pool you should see now your custom tab and field in the item details:

     

    Problems:

     

    • Own tab not displayed in ME21N and ME22N but displayed in ME23N

     

              o  You forget to code IF_EX_ME_PROCESS_PO_CUST~FIELDSELECTION_ITEM of ME_PROCESS_PO_CUST

     

              o  Compare to Note 1910516, you there is not “display” field you will not see the whole tab

     

     

     

    • Own field changeable in ME23N

     

              o  Mistake in declaration of screen and/or method SUBSRICBE of ME_GUI_PO_CUST

     

                  §  Refer in screen to your defined structure

     

                  §  Refer in method by ls_subscriber-struct_name to the same structure

     

    • Methods of ME_GUI_PO_CUST not proceeded

     

              o  Check your screen definition

     

                  §  You need to use both modules (event_pbo and event_pai) to get the method run, they are mandatory

     

    • Dump (PERFORM_NOT_FOUND            CX_SY_DYN_CALL_ILLEGAL_FORM ) when choosing the new tab

     

              o  You forgot to add the include lmeviewsf01 in the top include of your function module

     

    • System does not react like you expect

     

              o  Ensure that all your function modules are in the same function pool

     

    Viewing all 935 articles
    Browse latest View live


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