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

Enhancement in SAP

$
0
0

 

 

Enhancement

 

     The R/3 Enhancement concept allows us to add your own functionality to SAP’s standard business applications without having to modify the      original applications. SAP creates enhancements for specific programs, screens, and menus within standard R/3 applications. These enhancements      do not contain any functionality. Instead, the enhancements act as hooks where WE can HANG our own add-on functionality onto these hooks.

 

Advantages


1. They do not affect standard SAP source Code

 

          When you add new functionality to your SAP system using SAP’s exits, you do not alter the source code of standard SAP programs in any           way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but           exist separately from SAP’s standard software package.

 

2. They do not effect software updates

 

When you add new functionality to your SAP system using SAP’s enhancements, your objects (called customer objects) must adhere (remain) to strict naming conventions (standards). When it comes time to upgrade to a new software release, customer objects names ensure that they will not be affected by any changes or new additions to the standard software package.

    

Note: Customer enhancements may not available for all programs and screens found in the SAP System. You can only use customer exists in the SAP System.


 

 

   


 

 

 

  • Screen and Menu Exits to enhance the front end.
  • Function Exits to Enhance the Programs
  • Append Structure to enhance Back End

 

Note : In Procedural, we have two type


  1. Using subroutines           -           User Exits (Out Dated)
  2. Using Function Modules   -           Customer Exits

 

Customer Exits

 

The Entire SAP Product can be divided into 3 Parts

  1. Menu Exits
  2. Screen Exits
  3. Function Module Exits

 

 

1. Menu Exits :


Menu exits add items to the pull down menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications.

 

SAP created menu exits by defining special menu items in the menu painter. These special entries have function codes that begin with “+” (a plus sign). You specify the menu items text when activating the item in an add-on project.

 

2. Screen Exits :


Screen exits add fields to screens in R/3 applications. SAP create screen exits by placing special sunscreen areas on a standard R/3 screen and calling a customer sub screen from the standard screen’s flow logic.

 

 

3. Function Module Exits :


Function module exits add functionally to R/3 applications. Function module exits play a role in both menu and screen exits. When you add a new menu item to a standard pull down menu, you use a function module exit to define the actions that should take place once your menu is activated. Function module exits also control the data flow between standard programs and screen exit fields.

 

Business Add-Ins


SAP has introduced new enhancement technique Business Add-ins from release 4.6A Business Add-in is the new enhancement technique based on ABAP Objects. BADI is an exit point in a source that allows specific industry sectors, partners, and customers to attach additional software to standard SAP source code without modifying the original object.

The users of Business Add-ins can customize the logic according to requirement or they can use the standard logic one available.

SAP guarantees the upward compatibility of all business Add-in interfaces. Release upgrade do not affect enhancement calls from which the standard software nor do they affect the validity of call interfaces.

 

Two different views of BADI are available:


  • In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional functionality to standard SAP source code without having to modify the original object.

 

  • In the implementation view, the users of Business Add-Ins can enhance (customize) the logic that need or use a standard logic if one is available.

 

Difference Between Customer Exits and BADIs:

 

Customer Exit

BADI

Procedural Approach to work with Enhancements,

Object Oriented Approach to Work with Enhancements.

Is a two level infrastructure (SAP and customer solutions).

Allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like).

 

BADIs can be created at each level within such a system infrastructure.

Can only be implemented once and enhancements that can be used actively by any number of customers.

In addition, Business Add-ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example).

 

 

Source Code Enhancement


Source Code Enhancement is one of the enhancement technologies available under Enhancement Framework. Implementing this technology is also called as Source Code Plug-In. Technically the source code plug-in implementations are stored in a separate include program and not as part of the original source program.


There are two types of Source Code enhancements possible.


  • Implicit enhancement option
  • Explicit enhancement option

 

 

Implicit Enhancement

 

       Implicit enhancement points are basically points within ABAP code where an enhancement point is implied, and in which case can be created.      Examples of implicit enhancement points are at the beginning and end of FORM’s, at the end of a program, include or function module etc.

Explicit Enhancement

 

       Explicit enhancement points are basically hooks already coded into the program by SAP at various points of the code.

 

 

 

Your Suggestions Please.....

 

Regards,

Ramesh.T


Using xml sending E-mails.

$
0
0

I propose one more way to send xml messages from XI as a PDF attachment that does not exploit spool. It can be easy to use and probably be handy too.

Pre-Requsite: SAPConnect has to be configured appropriately on SAP XI.
Validity : If you are using WAS >=6.10 AND WAS <6.40 then implement the note 633265.For WAS>=6.40 note need not be implemented.
Settings to be done in SCOT :Double click the SMTP node in the SCOT transaction and set the internet address as shown below.
Set Internet Address
Set the output format of SAP for RAW Text as PDF .
Set Raw Text
Create RFC: Create RFC YXI_SEND_MAIL_ PDF_ATT in SE37 with the following parameters and source code:
Import Parameters :
SUBJECT type SO_OBJ_DES //Subject of the Mail
ATTACH_NAME1 type SOOD-OBJDES //Attachment Name
Tables Parameter :
IT_CONTENT type SOLI_TAB //Content of the Mail
IT_ATTACH type SOLI_TAB //Attachment data that has to be sent in PDF Format

 

 

source code use:

 

 

<span>function yxi_send_mail_pdf_att.*"----------------------------------------------------------------------*"*"Local Interface:*"  IMPORTING*"     VALUE(SUBJECT) TYPE  SO_OBJ_DES OPTIONAL*"     VALUE(ATTACH_NAME1) TYPE  SOOD-OBJDES OPTIONAL*"  TABLES*"      IT_CONTENT TYPE  SOLI_TAB OPTIONAL*"      IT_ATTACH TYPE  SOLI_TAB OPTIONAL*"----------------------------------------------------------------------  data: send_request       type ref to cl_bcs.  data: document           type ref to cl_document_bcs.  data: sender             type ref to cl_sapuser_bcs.  data sendername like sy-uname.  data: recipient          type ref to if_recipient_bcs.  data: exception_info     type ref to if_os_exception_info,  bcs_exception      type ref to cx_document_bcs.  data i_attachment_size type sood-objlen.  data spoolid type ref to tsp01-rqident.  data tline like tline occurs 0 with header line.* Creates persistent send request  send_request = cl_bcs=>create_persistent( ).  try.******Create txt mail document***************************      document = cl_document_bcs=>create_document(                                    i_type    = 'HTM'                                    i_text = it_content[]                                    i_subject = subject ).*************************************************************************Creates Attachment 1************************      call method document->add_attachment        exporting          i_attachment_type    = 'RAW'          i_attachment_subject = attach_name1          i_att_content_text =  it_attach[].* Add document to send request      call method send_request->set_document( document ).* Get sender object      sender = cl_sapuser_bcs=>create( sy-uname ).* Add sender      call method send_request->set_sender        exporting          i_sender = sender.************e-mail list**************************        translate it_recv-mailid to lower case.      recipient = cl_cam_address_bcs=>create_internet_address(     </span><a class="jive-link-email-small" href="mailto:'sravya.talanki@uk.ngrid.com">'sravya.talanki@uk.ngrid.com</a><span>').      call method send_request->add_recipient        exporting          i_recipient  = recipient          i_express    = 'U'          i_copy       = ' '          i_blind_copy = ' '          i_no_forward = ' '.***********Trigger e-mails immediately*****************************      send_request->set_send_immediately( 'X' ).      call method send_request->send( ).      commit work.    catch cx_document_bcs into bcs_exception.  endtry.endfunction.</span>

 

 

That is all! Test this using SE37 editor by passing sample content and attachment data and check whether you are able to view the PDF in your mail box before you configure a scenario in Integration Builder. We are ready to trigger XML messages as e-mails in the PDF format. Just map this RFC message to the XML message that has to be sent as an email from the integration repository. Map the content of mail to the node IT_CONTENT and attachment data to the node IT_ATTACH in the message mapping.

Changing the Page Format dynamically in a Smartform

$
0
0

Sometimes, it is required to change the pageformat of the smartform based on some condition like Plants etc.In those cases, it is redundant to copy the same form and make changes in the page format for each plant. Instead,this requirement can be easily achieved  via the use of field symbols.

 

The page format is stored in the global structure '%header', in the field 'pageformat' , of the main program of the generated Function Module of the Smartform.This can be changed by making use of a field symbol.Please check the below screen shots:

 

 

image1.png

image1.png

 

image1.png

SCN Trial Editions: SAP NetWeaver Application Server ABAP 7.4

$
0
0

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

 

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

 

SCN Trial as Virtual Appliance

 

The SCN trials of SAP NetWeaver Application Server ABAP 7.4 are provided as virtual appliance by the SAP Cloud Appliance Library (free of charge) and available with two different database flavors, i.e. on SAP HANA (in-memory database) and on SAP MaxDB (classical RDBMS). Both virtual appliances come with a detailed user guide describing how to set up and run these virtual appliances. Please find this user guide and additional tutorials on our How-to and FAQ page. To get access to these virtual appliances and run it on your own cloud service provider account please visit the SAP Store and use your SCN user to 'purchase' these free trial editions. For questions and feedback please post a message in the correspondingABAP trial thread.

 

 

tag_cloud_chart_grey_32.png

Get AS ABAP 7.4 on SAP HANA
[Trial Edition]

tag_cloud_chart_32.png

Get AS ABAP 7.4 on SAP MaxDB
[Trial Edition]

 

 

Tutorials and Sample Applications

 

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

 

ABAP for SAP HANA reference scenario

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

 

How to implement an OData service with SAP NetWeaver Gateway

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

 

How to build SAPUI5/HTML5 applications consuming OData services

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

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

$
0
0

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

 

Prerequisites

 

 

Tutorials and Guides

 

  • Watch the following video tutorial [5min] to learn how to get and set up an AS ABAP trial instance in your SAP Cloud Appliance Library account:

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

 

Frequently Asked Questions

 

Why are only a limited number of countries supported for purchasing the free AS ABAP 7.4 trials?

This is a limitation of the SAP Store and we are already trying to solve this issue. Please be patient...

 

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

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

 

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

Yes, as an AS ABAP on SAP HANA trial instance requires more virtual CPUs and memory than an AS ABAP on MaxDB trial instance you should use different instance types/sizes (see below). This has an impact on the charges of your cloud service provider as shown in the cost forecast of your SAP CAL account.

 

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

You have two options:

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

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

 

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

If you don't use your trial instance all day we recommend to use the 'activate and suspend manually' option. This setting is part of the instance creation wizard or available within the properties of your existing instance.

 

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

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

ZZ_SAMPLE_ALV_RPT - base code

$
0
0
*&---------------------------------------------------------------------*
*& Report  ZZ_SAMPLE_ALV_RPT
*&
*&---------------------------------------------------------------------*
*======================================================================*
*  Program Title       : Sample for making an arbitrary ALV Report     *
*  Author              : Neal Wilhite                                  *
*  Date                : 07/24/2013                                    *
*  Initial SAP Change Request #: NA
*----------------------------------------------------------------------*
*  Program Name        : ZZ_SAMPLE_ALV_RPT                             *
*  Description         : Simple starter program for an ALV.  I'll do   *
*      something simple with Sales Orders as an example.               *
*  Type:               : ALV Report                                    *
*  Run Frequency:      : As needed                                     *
*----------------------------------------------------------------------*
*                                                                      *
*                     MODIFICATION HISTORY                             *
*----------------------------------------------------------------------*
*                                                                      *
* Request    Date       ID           Descriptioncription               *
*----------------------------------------------------------------------*
* DV1K9XXXXX XX/XX/XXXX XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX *
************************************************************************

REPORT zz_sample_alv_rpt         NO STANDARD PAGE HEADING                                 MESSAGE-ID zsd                                 LINE-SIZE 200                                 LINE-COUNT 65.

*INCLUDE ZZ_SAMPLE_ALV_RPT_top.
TABLES:
        vbak,        vbap.

* Sales Order data type
TYPES: BEGIN OF ty_so.
TYPES:   vbeln          LIKE vbak-vbeln,        "Ship From         audat          LIKE vbak-audat,        "Document Date         vbtyp          LIKE vbak-vbtyp,        "SD document category         auart          LIKE vbak-auart,        "Sales Document Type         posnr          LIKE vbap-posnr,        "Sales Document Item         matnr          LIKE vbap-matnr,        "Material Number         charg          LIKE vbap-charg,        "Batch Number         kwmeng         LIKE vbap-kwmeng,       "Cumulative Order Quantity in Sales Units         meins          LIKE vbap-meins.        "Base Unit of Measure
types: END OF ty_so.

TYPES :
        tt_so     TYPE STANDARD TABLE OF ty_so.

** Internal tables.
DATA:
        it_so       TYPE tt_so.

* transfer structure
DATA:
        wa_so     TYPE ty_so.


INCLUDE z_otc_broker_edi867_rpt_scr.

INCLUDE zz_alv_mast_incl.

************************************************************************
START-OF-SELECTION.
************************************************************************

  PERFORM select_data TABLES it_so.

***********************************************************************
*            END-OF-SELECTION
***********************************************************************
END-OF-SELECTION.


* routine for building layout
  PERFORM layout_build USING st_layout.

* routine for the building the field catalog
  PERFORM fieldcat_init  USING it_fieldcat[].

* Get top-of-page.
  PERFORM events.  PERFORM z_comment_build USING it_top_of_page.  IF it_so[] IS NOT INITIAL.
*  Perform alv display    PERFORM alv_list_display.  ELSE.    MESSAGE s017.  "No data available for output display    EXIT.  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_NEW_SDF  text
*----------------------------------------------------------------------*
FORM select_data  TABLES   p_it_so  TYPE tt_so.  SELECT a~vbeln a~audat a~vbtyp a~auart         b~posnr b~matnr b~charg b~kwmeng b~meins         INTO CORRESPONDING FIELDS OF TABLE p_it_so         FROM ( vbak AS a                INNER JOIN vbap AS b                      ON  a~vbeln = b~vbeln              )         WHERE a~vbtyp = 'C'.

ENDFORM.                    " SELECT_DATA

*&--------------------------------------------------------------------*
*&      Form  Build Field Catalog
*&--------------------------------------------------------------------*
FORM fieldcat_init USING fieldcat TYPE slis_t_fieldcat_alv.  DATA:     pv_lt_fieldcat TYPE slis_fieldcat_alv.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 1.  pv_lt_fieldcat-fieldname    = 'VBELN'.  pv_lt_fieldcat-seltext_l    = 'SO DOC #'.  pv_lt_fieldcat-emphasize    = 'C41'.  pv_lt_fieldcat-outputlen    = 10.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 2.  pv_lt_fieldcat-fieldname    = 'AUDAT'.  pv_lt_fieldcat-seltext_l    = 'Doc Date'.  pv_lt_fieldcat-emphasize    = 'C41'.  pv_lt_fieldcat-outputlen    = 10.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 3.  pv_lt_fieldcat-fieldname    = 'VBTYP'.  pv_lt_fieldcat-seltext_l    = 'SO Cat.'.  pv_lt_fieldcat-emphasize    = 'C41'.  pv_lt_fieldcat-no_out       = 'X' ."g_no_out.  pv_lt_fieldcat-outputlen    = 7.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos       = 4.  pv_lt_fieldcat-fieldname     = 'AUART'.  pv_lt_fieldcat-seltext_l     = 'SO Type'.  pv_lt_fieldcat-emphasize     = 'C41'.  pv_lt_fieldcat-outputlen     = 7.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 5.  pv_lt_fieldcat-fieldname    = 'POSNR'.  pv_lt_fieldcat-seltext_l    = 'SO Item'.  pv_lt_fieldcat-emphasize    = 'C41'.  pv_lt_fieldcat-outputlen    = 7.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos       = 6.  pv_lt_fieldcat-fieldname     = 'MATNR'.  pv_lt_fieldcat-seltext_l     = 'Material #'.  pv_lt_fieldcat-emphasize     = 'C41'.  pv_lt_fieldcat-outputlen     = 18.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos       = 7.  pv_lt_fieldcat-fieldname     = 'CHARG'.  pv_lt_fieldcat-seltext_l    =  'Batch #'.  pv_lt_fieldcat-emphasize    = 'C41'.  pv_lt_fieldcat-outputlen    = 10.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 8.  pv_lt_fieldcat-fieldname    = 'KWMENG'.  pv_lt_fieldcat-seltext_l    = 'Wk.End Dt.'.  pv_lt_fieldcat-emphasize    = 'C31'.  pv_lt_fieldcat-outputlen    = 19.  APPEND pv_lt_fieldcat TO fieldcat.

*--
  CLEAR pv_lt_fieldcat.  pv_lt_fieldcat-col_pos      = 9.  pv_lt_fieldcat-fieldname    = 'MEINS'.  pv_lt_fieldcat-seltext_l    = 'OUM'.  pv_lt_fieldcat-emphasize    = 'C30'.  pv_lt_fieldcat-outputlen    = 2.  APPEND pv_lt_fieldcat TO fieldcat.


ENDFORM.                    "pv_FIELDCAT_INIT

How to write general code for an ALV Report

$
0
0
  1. Make the base code
  2. Include a generalized include of ALV forms
    • Holder
  3. One of the ALV forms must be non-generalized (without further work) so it does not go in the generalized include

Neal's templates for ABAP

$
0
0

Hi All,

 

I am working on a set of templates for SAP functionality.  They will be things that I write over and over again every time that I change companies. 

  • There will be a topic.
  • Then there will be a link.  The link will goto a new document that contains the template with notes on how to use it and what I consider reasonable documentation.
  • Then there will a little description

 

So this document will be my table of contents.

 

  1. Programming style sheets:
    1. http://en.wikipedia.org/wiki/The_Elements_of_Programming_Style
    2. http://www.sethi.org/classes/cet375/daily_lecture_notes/programming_style_sheet.phtml
    3. https://scn.sap.com/thread/593126
    4. http://www.sap-press.de/download/dateien/1948/sappress_official_abap_programming_guideline.pdf
    5. http://web.mit.edu/fss/dev/newdevstand.html
    6. Holder
  2. Protecting your access - Enqueue, Dequeue
    1. Holder
  3. Functional Spec Template
    1. http://scn.sap.com/docs/DOC-44167
  4. Waits between job steps
    1. Waits between job steps - Overview
      1. http://scn.sap.com/docs/DOC-44168
  5. Email Invoice to multiple recipients
    1. http://scn.sap.com/docs/DOC-41410
  6. General ALV Template
    1. http://scn.sap.com/docs/DOC-44541

 

This will hopefully grow to be to large for it's initial look and feel, so expect this core document to under go continuous reformatting. 

 

Some entries will disappear from this page.  Initially, I will be gathering multiple representative examples here until I can nail down the style that I prefer.  When they no longer fit me firmer standards, some of the best will be moved here (http://scn.sap.com/docs/DOC-43784)

 

 

Neal Wilhite


How to Create a Custom Print program with Smartforms for Payment Instruments(like Cheque,Payorder e.t.c) in SAP FI(Financials)(Transactions = F-58,FBZ5,FBZP)?

$
0
0

How to Create a Custom Print program with Smartforms for Payment Instruments(like Cheque,Payorder e.t.c) in SAP FI(Financials)(Transactions = F-58,FBZ5,FBZP)?

 

There are various payment instruments available in SAP FI,each of which is denoted technically in sap by the term 'Payment method'. Some of these instruments include 'Cheque Payment','Cash Payment','Payment Order','Bank Transfer PLS','Bank Transfer Current' e.t.c. Cheque and Payorder are the most commonly used instruments. Of course the FI consultant can create custom payment methods and map them to a country,by going to the following menu path in IMG(Customizing):

Financial Accounting(New) > Accounts Receivable and Accounts Payable > Business Transactions > Incoming Payments > Automatic Incoming Payments > Payment Method/Bank Selection for Payment Program > Set Up Payment Methods per Country for Payment Transactions

The name of the Standard Print Program for these Payment Instruments is 'RFFOUS_C'. If you look closely at this program,you will find an include named 'RFFORI01',this include program will contain SAP Script statements such as 'OPEN_FORM','WRITE_FORM' and 'CLOSE_FORM' e.t.c.,which can easily be opened in SAP Script Form transaction of 'SE71'. For example the default SAP Script attached to a cheque Payment instrument is 'F110_PRENUM_CHCK'. The standard print program 'RFFOUS_S' already contains pre-populated Payment instrument data in the form of structures,that can be added to a custom structure or internal table and passed to a smartform or an SAP Script.

 

Standard Structures pre-populated with data in the Standard Print Program:

The standard Structures that will be helpful for passing in data,include the following:

 

(01)REGUH(Settlement data from payment program):

This structure includes information related to the payment instrument such as:

(A)Vendor or Payee Number(reguh-empfg+1(10),reguh-lifnr)

(B)Vendor or Payee Name(reguh-znme1,reguh-znme2)

(C)Cheque Date(reguh-laufd)

(D)Cheque Amount in Number(reguh-rbetr)[Note: you can use the function module 'SPELL_AMOUNT' for converting the given cheque amount into words]

(E)Bank Document Number(reguh-belnr)

(F)Bank Document Date(reguh-laufd)

(G)Vendor or Payee Address Line(reguh-stras)

(H)Vendor or Payee City(reguh-ort01)

 

(02)REGUD(Form print transfer data):

This structure includes information related to the payment instrument such as:

(A)Cheque Number(reguh-chect)[This is basically is the lot number for the payment instrument which is defined as a series by the FI functional Consultant]

 

(03)PAYR(Payment Medium File):

This structure includes fields such as:

(A)short key for House Bank(payr-HBKID)(This can be used for determining the Payment Instrument being currently used)

(B)Cheque number(payr-CHECT)

(C)Currency key(payr-WAERS)

(D)Print User(payr-PRIUS)

(E)Bank number of the payee's bank(payr-ZBNKL)

(F)Name of the payee(payr-ZNME1)

(G)Title of the payee(payr-ZANRE)

(H)Fiscal Year(payr-GJAHR)

(I)Paying company code(payr-ZBUKR)

 

[Note]: To see all the fields in these structures,you can enter them in the Data Dictionary Transaction(SE11),to see a list of all the fields.

 

> The Print Program for these Payment instruments can be invoked in 2 ways:

(01)By posting a document for the given payment methods,you will be prompted to print that,using the Transaction 'F-58'(Payment with Printout:Header Data).

(02)By printing documents that have already been posted using the transaction 'FBZ5'(Print Form for Payment Document).

 

Procedure for attaching the Smartform in place of the standard Print Program(RFFOUS_C):

In order to attach the smartform,you need to create a replica of the Standard Print Program(RFFOUS_C) in customer namespace e.g: 'ZRFFOUS_C'.Next you will need to attach this replica in place of the standard program,by going to the Transaction 'FBZP'(Maintain Payment Program) and then click the 'Pmnt methods in country' button,in the position button enter in the 'country code',in our case it is PK(Pakistan) and the 'payment method' lets say 'C'(Cheque payment) Just Double click the payment method for which you want to attach the program. Now in the 'Payment medium' section,copy the name of your custom replica program within the 'Payment medium program' input field,just below the 'Use classic payment medium programs(RFFO)*' radio button and then click the save button to save this. This attaches your custom print program instead of the standard print program.

 

You can attach the same custom replica program on all payment methods and use conditional constructs to launch the relevant smarforms for each of the payment instruments. you can use a field such as 'short key for House Bank'(reguh-HBKID) to select whether the Payment method is 'NBPC'(custom created for the NBP project) cheque or Payorder 'NBPP'((custom created for the NBP project)) [OR] you can use the 'Payment Method for This Payment' field(reguh-RZAWE) to check for the payment method 'C'(For Cheque) and 'E'(For Payorder).

 

Figure 01(A) : Attaching Print Program in FBZP 'paymnt methods in country'

01_a_Attaching_Print_program_in_FBZP_paymnt_methods_in_country.png

 

Figure 01(B) : Position button country code to seek out payment methods

01_b_position_button_country_code_to_seek_out_payment_methods.png

 

Figure 01(C) : Select the Payment Method Row and click details button in  ApplicationToolbar

01_c_Select_the_payment_method_row_and_click_details_button_in_APPTB.png

 

Figure 01(D) : Attaching Print Program in FBZP and Click Save button to assign

01_d_Attaching_Print_program_in_FBZP_and_click_save_button_to_assign.png

 

Sample Source Code:

  IF reguh-RZAWE EQ 'C'."A - Load Smartform for a Cheque [Payment Method = C(Cheque)]

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING
         formname = 'ZFJ_FI_VENDOR_CHEQUE'
       IMPORTING
         fm_name  = fname.

    CALL FUNCTION fname
       EXPORTING
         header_data = header_data"Header Data
       TABLES
         item_data   = item_data."Item Data

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

elseIF reguh-RZAWE EQ 'E'."B - Load Smartform for a Payorder [Payment Method = E(Payorder)]

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING
         formname = 'ZFJ_FI_VENDOR_PAYORDER'
       IMPORTING
         fm_name  = fname.

    CALL FUNCTION fname
       EXPORTING
         header_data = header_data
       TABLES
         item_data   = item_data.

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

  ENDIF.

 

Testing the Final Cheque or Payorder:

In order to test the newly attached replica of Payment Instrument Print program,you have the following 2 ways:

(A) At the Time of posting the document at runtime using transaction F-58:

> When you post a document via the F-58 transaction,you will be prompted to print the payment instrument then and there. In case you have skipped that step,you can use the second method to print it.

(B)Using the Transaction FBZ5 for printing Payment Instruments based on already posted documents,incase the user did not print them while posting them:

> You can print Already posted documents in Transaction FBZ5(Print form for Payment Document). You need to provide in details such as document number,company code,Fiscal year,payment method e.t.c. Just make sure that you have checked the 'Print Immediately' checkbox. Now go the following menu path:

                          Check > Print > Old Check

This will trigger you custom program and select the smartform based on the selection provided in the Payment Method field. You can even set a breakpoint in your custom program to check whether its working or not. You can then print the payment instrument like cheque or payorder,or seek out a Print Preview of the smartform.

 

 

Figure 02(A) : Checking Vendor Cheque(FBZ5)


02_a_checking_vendor_cheque(FBZ5).png

 

 

 

Figure 02(B) : Checking Vendor Payorder(FBZ5)


02_b_checking_vendor_payorder(FBZ5).png

 

 

 

 

Figure 03(A) : Final Cheque Smartform Output

03_a_Final_Cheque_Smartform_Output.png

 

 

Figure 03(A) : Final Payorder Smartform Output

03_b_Final_Payorder_Smartform_Output.png

 

 

[Tip]:You can seek out all documents already posted by looking into a Transparent table named 'PAYR' (Payment Medium File). Its also populated as a structure when the Standard Print program or your custom replica of it is invoked. Details from this table can be used for printing these payment instruments in the FBZ5 Transaction.

 

> In case the data is not fetched from the Standard Structures,you will need to write alternate code for fetching it for example vendor details can be fetched from the Vendor Master data table named 'LFA1'(Vendor Master) or from Customer Master data based in the table named 'KNA1'(Customer Master).

 

Finalized Output of Payment Order and Cheque on Pre-printed stationary:

 

 

Final Payment Order printed on  pre-printed Stationary
Payment_Order[Preprinted Stationary].png

 

 

 

Final Cheque on pre-printed Stationary
Cheque[Preprinted Stationary].png

 

 

 

Legal

Fahad Javed's Copyrights

All Screen Shots taken,Fahad Javed's Logo are copyrights © 2010-2013 Fahad Javed. All Rights Reserved.

All the material written is a labour of hardwork carried out by the author. Kindly don't copy this material for commercial purposes. If a link is provided do provide the accredition to the author as follows:'© 2010-2013 Fahad Javed. All rights reserved.'.

All the terms used are copyrights of SAP AG  © 2013 SAP AG. All rights reserved. See the section 'SAP - Copyrights and Trademarks' for further details.

SAP - Copyrights and Trademarks

© 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, PowerPoint, Silverlight, and Visual Studio 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, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7, POWER6+, POWER6, POWER, PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere, Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the United States and other countries.

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

Oracle and Java are registered trademarks of Oracle and its affiliates.

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.

Apple, App Store, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri, and Xcode are trademarks or registered trademarks of Apple Inc.

IOS is a registered trademark of Cisco Systems Inc.

RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry Torch, BlackBerry Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry App World are trademarks or registered trademarks of Research in Motion Limited.

Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads, Google Mobile Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice, Google Mail, Gmail, YouTube, Dalvik and Android are trademarks or registered trademarks of Google Inc.

INTERMEC is a registered trademark of Intermec Technologies Corporation.

Wi-Fi is a registered trademark of Wi-Fi Alliance.

Bluetooth is a registered trademark of Bluetooth SIG Inc.

Motorola is a registered trademark of Motorola Trademark Holdings LLC.

Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, SAP HANA, 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 Software Ltd. Business Objects is an SAP company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase Inc. Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are registered trademarks of Crossgate AG in Germany and other countries. Crossgate 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.

Using ABAP Memory with a Report executing in Background

$
0
0

Sometimes,there is a unique requirement in the project - we have a report which will call an another report in background.The first report shall transport the data to the called report and after computation ,the second report shall throw back the results to the first report.This can be easily achieved by using ABAP memory and Submit statement.Let us check,how :

 

The first report shall pass the data to ABAP Memory using Export statement and then call the second report using SUBMIT statement:

 

 

   DATA: lv_number           TYPE tbtcjob-jobcount,
       lv_name                    TYPE tbtcjob-jobname VALUE 'JOB_TEST',
       lt_print_parameters    TYPE pri_params ,
       lv_valid_flag(1)           TYPE c.

  DATA : lit_joblist  TYPE TABLE OF tbtcstep,
             wa_joblist TYPE tbtcstep.

  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = lv_name
    IMPORTING
      jobcount         = lv_number
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF sy-subrc = 0 .

    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
        mode                 = 'BATCH'
        no_dialog            = 'X'
        destination          = 'LOCL'
        new_list_id          = 'X'
      IMPORTING
        out_parameters       = lt_print_parameters
        valid                = lv_valid_flag
      EXCEPTIONS
        invalid_print_params = 2
        OTHERS               = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    PERFORM export_to_memory.



    SUBMIT zqma_archive_create
    TO SAP-SPOOL
    VIA JOB lv_name NUMBER lv_number
    WITHOUT SPOOL DYNPRO
    SPOOL PARAMETERS lt_print_parameters
    AND RETURN.



    IF sy-subrc = 0.

      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_number
          jobname              = lv_name
          strtimmed            = 'X'
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          OTHERS               = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.
    ENDIF.
  ENDIF.

 

===================================================================================================================

 

   FORM export_to_memory .

  EXPORT gt1_certificate_data[]
         vbak-vbeln
         vbap-posnr
         objk-sernr
         gv_charg
         t001w-werks
         zqma_cert_adm_11-brand
         sy-repid
         g_cpack
         gv_flg
         afpo-aufnr
         gs_crane-sernr
         mara-matnr
         gs_crane-vbeln
         gs_crane-matnr
         gs_crane-ppaufnr TO MEMORY ID 'ZQMA_ARCHIVE'.

ENDFORM.                    " EXPORT_TO_MEMORY

 

====================================================================================================================

  REPORT  zqma_archive_create.

INITIALIZATION.

 

* Types decleration
  TYPES: BEGIN OF ty_certificate_data,
         checkbox     TYPE char1,         " for selection.
         certpack     TYPE zqma_certpack, " Certificate Package
         certtype     TYPE zqma_certtype, " Certificate Type
         certdesc     TYPE zqma_certdesc, " Certificate Description
         matnr        TYPE mara-matnr,    " Material number
         maktx        TYPE makt-maktx,    " Material description
         sernr        TYPE gernr,         " serial number
         langkey      TYPE spras,         " Language Key
         quantity     TYPE i,             " no. of copies to be printed.
         langdone     TYPE char1,
         END OF ty_certificate_data.


* Internal Tables decleration
  DATA: gt_cert_data_memory          TYPE STANDARD TABLE OF ty_certificate_data,
        gt1_certificate_data         TYPE STANDARD TABLE OF ty_certificate_data,
        lt_zqma_cert_adm_06          TYPE STANDARD TABLE OF zqma_cert_adm_06,
        ls_zqma_cert_adm_06          TYPE zqma_cert_adm_06,
        lt_tfdir                     TYPE STANDARD TABLE OF tfdir.

*Local Data
  DATA:  lv_okay                     TYPE         char1,
         l_report                    LIKE         sy-repid,
         wa_cert_data_memory         LIKE LINE OF gt_cert_data_memory,
         lv_count                    TYPE         i,
         lv_langkey                  TYPE         zqma_cert_adm_14-lang,
         lt_cert_data_memory_temp    LIKE         gt_cert_data_memory,
         lv_message                  TYPE         string,
         gv_total                    TYPE         i,
         gv_curr                     TYPE         i.


*Local Data
  DATA: l_vbeln                      TYPE        vbak-vbeln,
        l_posnr                      TYPE        vbap-posnr,
        l_sernr                      TYPE        gernr,
        l_charg                      TYPE        charg_d,
        l_werks                      TYPE        t001w-werks,
        l_brand                      TYPE        zqma_cert_adm_11-brand,
        l_repid                      TYPE        sy-repid,
        l_aufnr                      TYPE        afpo-aufnr,
        l_crane_sernr                TYPE        gernr,
        l_matnr                      TYPE        mara-matnr,
        l_crane_vbeln                TYPE        vbeln_va,
        l_crane_matnr                TYPE        matnr,
        l_crane-ppaufnr              TYPE        afpo-aufnr.

  DATA: l_cpack                      TYPE        zqma_certpack,
        l_flg                        TYPE        c.

*Constants
  CONSTANTS:
     lc_x                            TYPE c      VALUE  'X',
     lc_a                            TYPE c      VALUE  'A'.

* Importing required Data
IMPORT
       gt1_certificate_data[]
       vbak-vbeln             = l_vbeln
       vbap-posnr             = l_posnr
       objk-sernr             = l_sernr
       gv_charg               = l_charg
       t001w-werks            = l_werks
       zqma_cert_adm_11-brand = l_brand
       sy-repid               = l_repid
       g_cpack                = l_cpack
       gv_flg                 = l_flg
       afpo-aufnr             = l_aufnr
       gs_crane-sernr         = l_crane_sernr
       mara-matnr             = l_matnr
       gs_crane-vbeln         = l_crane_vbeln
       gs_crane-matnr         = l_crane_matnr
       gs_crane-ppaufnr       = l_crane-ppaufnr

       from memory id 'ZQMA_ARCHIVE'.


  IF gt1_certificate_data[] IS NOT INITIAL.

* may be no lines are selected.
    CLEAR: lv_okay.
    LOOP AT gt1_certificate_data TRANSPORTING NO FIELDS WHERE checkbox = lc_x.
      lv_okay = lc_x.
    ENDLOOP.

    IF lv_okay <> lc_x.
    ELSE.
      CLEAR: gt_cert_data_memory.
      gt_cert_data_memory[] = gt1_certificate_data[].
      DELETE gt_cert_data_memory WHERE checkbox NE lc_x.

* filter certificate records as per users wish considering language
* records maintained.
      CLEAR lt_cert_data_memory_temp[].

      LOOP AT gt_cert_data_memory INTO wa_cert_data_memory.

        CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT'
          EXPORTING
            input  = wa_cert_data_memory-langkey
          IMPORTING
            output = lv_langkey.

        SELECT SINGLE COUNT( * ) INTO lv_count
          FROM zqma_cert_adm_14
          WHERE certtype = wa_cert_data_memory-certtype
            AND lang = lv_langkey.                          "#EC WARNOK

        IF sy-subrc = 0.
          APPEND wa_cert_data_memory TO lt_cert_data_memory_temp.
          CONTINUE.
        ELSE.
          APPEND wa_cert_data_memory TO lt_cert_data_memory_temp.
        ENDIF.
      ENDLOOP.

      CLEAR: wa_cert_data_memory,
             gt_cert_data_memory[].

      gt_cert_data_memory[] = lt_cert_data_memory_temp[].

      EXPORT gt_certificate_data
      FROM gt_cert_data_memory TO MEMORY ID 'CERTDATA'.

      DESCRIBE TABLE gt_cert_data_memory LINES gv_total.
      CLEAR:  gv_curr.

      EXPORT gv_total TO MEMORY ID  'TOTAL'.
      EXPORT gv_curr  TO MEMORY ID  'CURR'.

      IF gt_cert_data_memory IS NOT INITIAL.
        SELECT
           certtype
           certtypeprg FROM zqma_cert_adm_06
          INTO CORRESPONDING FIELDS OF TABLE  lt_zqma_cert_adm_06
          FOR ALL ENTRIES IN gt_cert_data_memory
          WHERE certtype = gt_cert_data_memory-certtype
          AND  werks = l_werks.
        IF sy-subrc = 0.

          SORT lt_zqma_cert_adm_06 BY
          certtype
          werks.

          SELECT * FROM tfdir INTO TABLE lt_tfdir
          FOR ALL ENTRIES IN lt_zqma_cert_adm_06
          WHERE  funcname = lt_zqma_cert_adm_06-certtypeprg. "#EC CI_GENBUFF

          IF sy-subrc = 0.
            SORT lt_tfdir BY funcname.
          ENDIF.
        ENDIF.
      ENDIF.

      LOOP AT gt_cert_data_memory INTO wa_cert_data_memory.

        READ TABLE lt_zqma_cert_adm_06
        WITH KEY certtype = wa_cert_data_memory-certtype
        INTO ls_zqma_cert_adm_06
        BINARY SEARCH.

        IF sy-subrc EQ 0.
          l_report = ls_zqma_cert_adm_06-certtypeprg.
        ELSE.
          MESSAGE text-009 TYPE 'E' DISPLAY LIKE 'I'.
        ENDIF.

*check FM maintained exists in the system.
*
        READ TABLE lt_tfdir
        WITH KEY funcname = l_report TRANSPORTING NO FIELDS BINARY SEARCH.
        IF sy-subrc <> 0.
          CONCATENATE text-010 l_report text-011
            INTO lv_message SEPARATED BY space.
          MESSAGE lv_message TYPE 'E' DISPLAY LIKE 'I'.
        ENDIF.

        IMPORT gv_curr_1 TO gv_curr FROM MEMORY ID 'CURR'.
        gv_curr = gv_curr + 1.
        EXPORT gv_curr TO MEMORY ID 'CURR'.

        l_charg = wa_cert_data_memory-sernr.
        l_flg = lc_a.

* calling the driver programs for certificates
        CALL FUNCTION l_report
          EXPORTING
            pp_vbeln           = l_vbeln
            pp_posnr           = l_posnr
            pp_sernr           = l_sernr
            pp_charg           = l_charg
            pp_werks           = l_werks
            pp_matnr           = wa_cert_data_memory-matnr
            pp_brand           = l_brand
            pp_langu           = wa_cert_data_memory-langkey
            pp_callpr          = l_repid
            pp_certty          = wa_cert_data_memory-certtype
            pp_quanty          = wa_cert_data_memory-quantity
            pp_flag            = l_flg
            pp_certpack        = l_cpack
            pp_aufnr           = l_aufnr
            pp_gernr           = wa_cert_data_memory-sernr
            pp_crane_sernr     = l_crane_sernr
            pp_mara_matnr      = l_matnr
            pp_crane_vbeln     = l_crane_vbeln
            pp_crane_matnr     = l_crane_matnr
            pp_syrepid         = l_repid
            pp_assembled_order = l_crane-ppaufnr.

      ENDLOOP.

      FREE MEMORY ID : 'TOTAL', 'CURR', 'TABLE', 'CERTIFICATE_DATA'.

    ENDIF.
  ENDIF.

****Do not forget to place all the code in the called report after the initialization event.

 

Generic XML TAG Identification & Virus Scan

$
0
0

Scenario: Service PO, which is being created by client, needs to be validated against the Service Invoice (provided by municipalities), only then Incoming invoice will be created against the service PO in client system.

Client is dealing with hundreds of municipalities, End user receives file automatically from municipalities via PI or via email which he can upload manually as well.

 

Problem Statement: Each municipality is having different TAGS and XML structure as well along with the municipality identifiers. Each municipality can also change its XML file structure any time of the year.  PI can read the XML file and identify the municipality but JAVA coding was required. Also to handle all these challenges JAVA coding needs to be modified when municipality adjust its XML format.

 

Solution: In order to identify the municipality we have come up with a Generic solution as follows:

1.        1. Read the file and perform virus scan to identify the malicious threat (if any)

2.        2. Read the XML TAGS and compares it with stored municipality identifier list in customizing.

      3. Finally sends back the Municipality identifier and file to PI which uses a rule based mechanism to break down file into the correct data structure and pass    back to our solution for further processing.

 

 

Use the text file, provided in attachments to copy and paste the Report ‘Z_XML_TAG_IDENT_VIRUS_SCAN’ code directly. Apart from this below steps need to be provided:

 

 

1.       1. Complete the Virus scan profile customizing by providing Active scan profile, group for default profile ‘/SCET/GUI_UPLOAD’ of file upload feature.

          This can be maintained at SPRO->SAP NetWeaver->Application Server->System Administration->Virus Scan Interface->Define Virus Scan Profiles

 

     2. Create a custom customizing table for maintaining TAGS and identifiers.

 

 

     Refer attchment document for both the above steps.

Withholding tax code upload in vendor master through BDC

$
0
0

Hello,

i give a programming for withholding tax code upload in vendor master through BDC.

 

 

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

*& Report  ZFIR_FK02_NEW

*&

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

*&

*&

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

 

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

*                PROGRAM INFORMATION

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

*  PROGRAM....... ZFIB_FK02_WITHHOLDINGTAX

*  TITLE......... WITHHOLDING TAX CODE UPDATE IN VENDOR MASTER

*  AUTHOR........ SABYASACHI KARFORMA

 

* START DATE.... 11/07/2013

* END DATE.......11/07/2013

* DEV.CLASS......ZFI

* TCODE..........

*  R/3 RELEASE....SAP ECC 6.0

*  TRANSPORTNR....AEDK900270

*  COPIED FROM... N/A

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

*                PROGRAM FUNCTION:

* This conversion program is to Upload WITHHOLDING TAX CODE UPDATE IN VENDOR MASTER.

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

*  PROGRAM TYPE.. Executable

*  LOGICAL DB.... N/A

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

 

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

*                CHANGE HISTORY

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

*  DATE CHANGE... <Date of change written>

*  AUTHOR........ <Author name>

*  CHANGE DESCR.. <Description of change>

*  R/3 RELEASE... <Release>

*  TRANSPORTNR... <Transport number>

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

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

 

report zfib_fk02_withholdingtax.

 

type-pools: truxs.

 

data : it_intern type  alsmex_tabline occurs 0 with header line ,

        ls_itab type alsmex_tabline.

 

data : t_bdcdata type table of bdcdata,

        w_bdcdata like line of t_bdcdata.

 

types : begin of ty_final,

           lifnr      type lfa1-lifnr,           " vendor No

           bukrs      type bukrs,                " company code

           witht1     type witht,                " Indicator for withholding tax type

           wt_withcd1 type wt_withcd,            " Withholding tax code

           t_subjct1  type wt_subjct,            " Subject to withholding tax

           qsrec1     type qsrec,                " Type of recipient

         end of ty_final.

 

data : lt_final type table of ty_final,

        ls_final like line of lt_final.

 

selection-screen begin of block b1 with frame.

parameters : p_flname type rlgrap-filename.

selection-screen end of block b1.

 

initialization.

   clear : ls_final.

   refresh : lt_final.

 

at selection-screen on value-request for p_flname.

 

   call function 'KD_GET_FILENAME_ON_F4'

     exporting

       field_name    = 'P_FLNAME'

     changing

       file_name     = p_flname

     exceptions

       mask_too_long = 1

       others        = 2.

 

start-of-selection.

   perform excel_upload.

   perform update_data.

 

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

*&      Form  excel_upload

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

*       text

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

form excel_upload.

 

   call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     exporting

       filename                = p_flname

       i_begin_col             = '0001'

       i_begin_row             = '0003'

       i_end_col               = '0040'

       i_end_row               = '9999'

     tables

       intern                  = it_intern

     exceptions

       inconsistent_parameters = 1

       upload_ole              = 2

       others                  = 3.

 

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

   data : lv_index type i.

   field-symbols <fs>.

   sort it_intern by row col.

   clear it_intern.

   loop at it_intern.

     move it_intern-col to lv_index.

     assign component lv_index of structure ls_final to <fs>.

     move it_intern-value to <fs>.

     at end of row.

       call function 'CONVERSION_EXIT_ALPHA_INPUT'

         exporting

           input  = ls_final-lifnr

         importing

           output = ls_final-lifnr.

       append ls_final to lt_final.

       clear ls_final.

     endat.

   endloop.

 

endform.                    "excel_upload

 

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

*&      Form  bdc

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

*       text

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

form update_data.

 

   data : lt_lfbw  type table of flfbw,

          ls_lfbw  type flfbw.

 

   data : lt_lfbw_old  type table of lfbw,

          ls_lfbw_old  type lfbw.

 

   if not lt_final[] is initial.

     select * from lfbw into table lt_lfbw_old

              for all entries in lt_final

              where lifnr = lt_final-lifnr

                and bukrs = lt_final-bukrs

                and witht = lt_final-witht1

                and wt_withcd = lt_final-wt_withcd1

                and wt_subjct = lt_final-t_subjct1

                and qsrec     = lt_final-qsrec1.

 

   endif.

 

*  BREAK-POINT.

   loop at lt_final into ls_final.

     clear ls_lfbw.

     refresh lt_lfbw.

     ls_lfbw-mandt = sy-mandt.

     ls_lfbw-lifnr = ls_final-lifnr.

     ls_lfbw-bukrs = ls_final-bukrs.

     ls_lfbw-witht = ls_final-witht1.

     ls_lfbw-wt_withcd = ls_final-wt_withcd1.

     ls_lfbw-wt_subjct = ls_final-t_subjct1.

     ls_lfbw-qsrec     = ls_final-qsrec1.

     clear ls_lfbw_old.

     read table lt_lfbw_old into ls_lfbw_old

                            with key lifnr = ls_final-lifnr

                                     bukrs = ls_final-bukrs

                                     witht = ls_final-witht1

                                     wt_withcd = ls_final-wt_withcd1

                                     wt_subjct = ls_final-t_subjct1

                                     qsrec     = ls_final-qsrec1.

     if sy-subrc eq 0.

       ls_lfbw-kz = 'U'.

     else.

       ls_lfbw-kz = 'I'.

     endif.

     append ls_lfbw to lt_lfbw.

     call function 'FI_WT_VENDOR_UPDATE'

       tables

         t_xlfbw = lt_lfbw

         t_ylfbw = lt_lfbw.

     if sy-subrc eq 0.

       commit work.

     else.

       write :/ 'Error in Record --'ls_final-lifnr, '..', ls_final-bukrs, '..',

                ls_final-witht1, '..', ls_final-wt_withcd1.

     endif.

     clear ls_final.

   endloop.

 

   sort lt_final by lifnr.

   delete adjacent duplicates from lt_final comparing lifnr.

 

*  BREAK-POINT.

   loop at lt_final into ls_final.

     perform bdc_dynpro      using 'SAPMF02K'     '0106'.

     perform bdc_field       using 'BDC_CURSOR'   'RF02K-D0610'.

     perform bdc_field       using 'BDC_OKCODE'   '/00'.

     perform bdc_field       using 'RF02K-LIFNR'  ls_final-lifnr.

     perform bdc_field       using 'RF02K-BUKRS'  ls_final-bukrs.

     perform bdc_field       using 'RF02K-D0610'  'X'.

 

     perform bdc_dynpro      using 'SAPMF02K'            '0610'.

     perform bdc_field       using 'BDC_OKCODE'          'ENTR'.

 

     perform bdc_field       using 'BDC_CURSOR'          'LFBW-QSREC(01)'.

 

     perform bdc_field       using 'LFB1-QLAND'          'IN'.

 

     call transaction 'FK02' using t_bdcdata

                    mode 'E'.

     if sy-subrc eq 0.

       commit work.

     endif.

     clear t_bdcdata[].

   endloop.

 

 

 

endform.                   "update_data

 

 

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

*&      Form  bdc_dynpro

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

*       text

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

*      -->PROGRAM    text

*      -->DYNPRO     text

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

form bdc_dynpro using program dynpro.

   clear w_bdcdata.

   w_bdcdata-program  = program.

   w_bdcdata-dynpro   = dynpro.

   w_bdcdata-dynbegin = 'X'.

   append w_bdcdata to t_bdcdata.

endform.                    "BDC_DYNPRO

 

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

*        Insert field                                                  *

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

form bdc_field using fnam fval.

   clear w_bdcdata.

   w_bdcdata-fnam = fnam.

   w_bdcdata-fval = fval.

   append w_bdcdata to t_bdcdata.

endform.                    "bdc_field

 

 

Regards

Sabyasachi

Internal Order master (KO01) upload program

$
0
0

Hello,

kindly follow this program to upload internal order master. Explicit error handling also present in this code.

 

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

*                PROGRAM INFORMATION

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

*  PROGRAM....... ZFI_KO01_BDC

*  TITLE......... INTERNAL ORDER MASTER UPLOAD

*  AUTHOR........ SABYASACHI KARFORMA

 

* START DATE.... 15/07/2013

* END DATE.......16/07/2013

* DEV.CLASS......ZFI

* TCODE..........ZKO01_BDC

*  R/3 RELEASE....SAP ECC 6.0

*  TRANSPORTNR...  AEDK900286

*  COPIED FROM... N/A

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

*                PROGRAM FUNCTION:

* This conversion program is to Upload INTERNAL ORDER MASTER.

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

*  PROGRAM TYPE.. Executable

*  LOGICAL DB.... N/A

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

 

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

*                CHANGE HISTORY

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

*  DATE CHANGE... <Date of change written>

*  AUTHOR........ <Author name>

*  CHANGE DESCR.. <Description of change>

*  R/3 RELEASE... <Release>

*  TRANSPORTNR... <Transport number>

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

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

 

 

 

 

 

report zfi_ko01_bdc

        no standard page heading line-size 255.

 

 

types: begin of ty_ko01,

        auart type auart,

        ktext type coas-ktext,

        bukrs type bukrs,

        gsber type coas-gsber,

        werks type werks_d,

        scope type char5,

        prctr type prctr,

        waers type aufwaers,

        astkz type c,

        end of ty_ko01.

 

data: it_ko01 type standard table of ty_ko01,

       wa_ko01 type ty_ko01.

 

data: bdcdata like bdcdata occurs 0 with header line.

 

 

data: it_msg type standard table of bdcmsgcoll,

       wa_msg type bdcmsgcoll.

 

data: it_excel type standard table of alsmex_tabline initial size 0,

       wa_excel type alsmex_tabline.

 

data: message(90) type c.

 

data: it_vrm type vrm_values,

       wa_vrm type vrm_value.

 

 

 

selection-screen: begin of block b1 with frame title text-001.

parameters : p_file type rlgrap-filename obligatory,

              beg_col type i default '1' no-display,

              end_col type i default '9' no-display,

              beg_row type i default '6' no-display,

              end_row type i default  '9999' no-display,

              update type c as listbox visible length 20.

selection-screen: end of block b1.

 

at selection-screen output.

 

   wa_vrm-key = 'A'.

   wa_vrm-text = 'FOREGROUND'.

   append wa_vrm to it_vrm.

 

    wa_vrm-key = 'E'.

   wa_vrm-text = 'ERROR DISPLAY'.

   append wa_vrm to it_vrm.

 

    wa_vrm-key = 'N'.

   wa_vrm-text = 'BACKGROUND'.

   append wa_vrm to it_vrm.

   clear wa_vrm.

  call function 'VRM_SET_VALUES'

    exporting

      id                    = 'UPDATE'

      values                = it_vrm

*  EXCEPTIONS

*    ID_ILLEGAL_NAME       = 1

*    OTHERS                = 2

            .

  if sy-subrc <> 0.

* Implement suitable error handling here

  endif.

 

 

at selection-screen on value-request for p_file.

   call function 'F4_FILENAME'

    exporting

      program_name        = syst-cprog

      dynpro_number       = syst-dynnr

*     FIELD_NAME          = ' '

    importing

      file_name           = p_file

             .

 

 

start-of-selection.

 

 

 

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

   exporting

     filename                      = p_file

     i_begin_col                   = beg_col

     i_begin_row                   = beg_row

     i_end_col                     = end_col

     i_end_row                     = end_row

   tables

     intern                        = it_excel

* EXCEPTIONS

*   INCONSISTENT_PARAMETERS       = 1

*   UPLOAD_OLE                    = 2

*   OTHERS                        = 3

           .

if sy-subrc eq 0.

* Implement suitable error handling here

* LOOP  AT IT_EXCEL INTO WA_EXCEL WHERE

 

  loop at it_excel into wa_excel.

*BREAK AN_ABAP1.

    case wa_excel-col.

      when '0001'.

        wa_ko01-auart = wa_excel-value.

       when '0002'.

        wa_ko01-ktext = wa_excel-value.

        when '0003'.

        wa_ko01-bukrs = wa_excel-value.

         when '0004'.

        wa_ko01-gsber = wa_excel-value.

        when '0005'.

        wa_ko01-werks = wa_excel-value.

         when '0006'.

        wa_ko01-scope = wa_excel-value.

         when '0007'.

        wa_ko01-prctr = wa_excel-value.

         when '0008'.

        wa_ko01-waers = wa_excel-value.

        when '0009'.

        wa_ko01-astkz = wa_excel-value.

        endcase.

         at end of row.

         append wa_ko01 to it_ko01.

          clear wa_ko01.

        endat.

 

*       CLEAR WA_EXCEL.

        endloop.

        else.

          message 'ERROR IN DATA UPLOAD FROM EXCEL FILE' type 'E'.

        endif.

 

 

*perform open_group.

 

loop at it_ko01 into wa_ko01.

   clear bdcdata.

   refresh bdcdata.

 

perform bdc_dynpro      using 'SAPMKAUF' '0100'.

perform bdc_field       using 'BDC_CURSOR'

                               'COAS-AUART'.

perform bdc_field       using 'BDC_OKCODE'

                               '/00'.

perform bdc_field       using 'COAS-AUART'

                              " '0400'.

                              wa_ko01-auart.

perform bdc_dynpro      using 'SAPMKAUF' '0600'.

perform bdc_field       using 'BDC_OKCODE'

                               '=BUT2'.

perform bdc_field       using 'COAS-KTEXT'

                               "'Training Proram'.

                                wa_ko01-ktext.

perform bdc_field       using 'BDC_CURSOR'

                               'COAS-SCOPE'.

perform bdc_field       using 'COAS-BUKRS'

                               "'1111'.

                                wa_ko01-bukrs.

perform bdc_field       using 'COAS-GSBER'

                               "'7777'.

                                wa_ko01-gsber.

perform bdc_field       using  'COAS-WERKS'

                                wa_ko01-werks.

perform bdc_field       using 'COAS-SCOPE'

                              " 'OCOST'.

                               wa_ko01-scope.

perform bdc_field       using 'COAS-PRCTR'

                               "'7777'.

                                wa_ko01-prctr.

perform bdc_dynpro      using 'SAPMKAUF' '0600'.

perform bdc_field       using 'BDC_OKCODE'

                               '=VARI'.

perform bdc_field       using 'COAS-KTEXT'

                               "'Training Proram'.

                               wa_ko01-ktext.

perform bdc_field       using 'BDC_CURSOR'

                               'COAS-ASTKZ'.

perform bdc_field       using 'COAS-WAERS'

                               "'INR'.

                                wa_ko01-waers.

perform bdc_field       using 'COAS-ASTKZ'

                               "'X'.

                                wa_ko01-astkz.

perform bdc_dynpro      using 'SAPMKAUF' '0600'.

perform bdc_field       using 'BDC_OKCODE'

                               '=SICH'.

perform bdc_field       using 'COAS-KTEXT'

                               "'Training Proram'.

                               wa_ko01-ktext.

perform bdc_field       using 'BDC_CURSOR'

                               'COAS-AUTYP'.

perform bdc_field       using 'COAS-WAERS'

                               "'INR'.

                               wa_ko01-waers.

*perform bdc_transaction using 'KO01'.

 

call transaction 'KO01' using bdcdata mode update update 'S' messages into it_msg.

clear wa_ko01.

*CONTINUE.

endloop.

 

*perform close_group.

 

 

 

 

loop at it_msg into wa_msg.

   call function 'FORMAT_MESSAGE'

    exporting

      id              = wa_msg-msgid

      lang            = 'EN'

      no              = wa_msg-msgnr

      v1              = wa_msg-msgv1

      v2              = wa_msg-msgv2

      v3              = wa_msg-msgv3

      v4              = wa_msg-msgv4

    importing

      msg             = message

*   EXCEPTIONS

*     NOT_FOUND       = 1

*     OTHERS          = 2

             .

   if sy-subrc eq 0.

* Implement suitable error handling here

     if sy-tabix = 1.

     write:/ 'MESSAGE TYPE',

              sy-vline,

             'MESSAGE TEXT'.

     write:/ sy-uline.

     endif.

     write:/ wa_msg-msgtyp under 'MESSAGE TYPE', 14 sy-vlinemessage under 'MESSAGE TEXT'.

     write:/ space.

     write:/ sy-uline.

 

   endif.

 

   endloop.

 

 

form bdc_dynpro using program dynpro.

   clear bdcdata.

   bdcdata-program  = program.

   bdcdata-dynpro  = dynpro.

   bdcdata-dynbegin = 'X'.

   append bdcdata.

endform.

 

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

*        Insert field                                                  *

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

form bdc_field using fnam fval.

*  if fval <> nodata.

     clear bdcdata.

     bdcdata-fnam = fnam.

     bdcdata-fval = fval.

     append bdcdata.

*  endif.

endform.

 

 

 

 

Thanks

Sabyasachi

BPO creation (PS Module) program Through BDC

$
0
0

Dear,

there is a program which creates BPO. ITS very important BDC in PS module.

 

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

*                PROGRAM INFORMATION

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

*  PROGRAM....... ZPS_BPO_CREATE_BDC

*  TITLE......... Creation Of BPO

*  AUTHOR........ SABYASACHI KARFORMA

 

* START DATE.... 05/07/2013

* END DATE.......05/07/2013

* DEV.CLASS......ZPS

* TCODE..........ZPS_BPO_UPLOAD

*  R/3 RELEASE....SAP ECC 6.0

*  TRANSPORTNR... AEDK900252

*  COPIED FROM... N/A

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

*                PROGRAM FUNCTION:

* This conversion program is to Upload BPO.

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

*  PROGRAM TYPE.. Executable

*  LOGICAL DB.... N/A

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

 

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

*                CHANGE HISTORY

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

*  DATE CHANGE... <Date of change written>

*  AUTHOR........ <Author name>

*  CHANGE DESCR.. <Description of change>

*  R/3 RELEASE... <Release>

*  TRANSPORTNR... <Transport number>

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

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

 

 

 

 

report zps_bpo_create_bdc

        no standard page heading line-size 255.

 

types: begin of ty_header,

        extnr type extnr,

        ref_extnr type extnr,

*       KOKRS TYPE KOKRS,

        meeht type meins,

*       KSTAR TYPE KSTAR,

        bukrs type bukrs,

        werks type werks_d,

        prctr type prctr,

        kstar type kstar,

        btgrp type btgrp,

        ktext type ktext,

        ltext type kltxt,

        klvar type ck_klvar,

        menge type menge_kpf,

        end of ty_header.

 

types: begin of ty_item,

        extnr type extnr,

        typps type typps,

        herk2 type herk2,

        herk3 type herk3,

        menge type menge_kpf,

        meeht type meins,

        ltext type kltxt,

        lpreis type lpreis,

        lpeinh type peinh,

        kstar type kstar,

        lpreifx type lpreifx,

        arbpl type kkek_arbpl,

        arbplwerk type kkek_arbplwerk,

        end of ty_item.

 

*include bdcrecx1.

 

parameters: p_file type localfile obligatory.

 

parameters: beg_row type i default '2' no-display,

       beg_col type i default '2' no-display ,

       end_col type i default '25' no-display,

       end_row type i default '9999' no-display.

 

data: it_excel type standard table of alsmex_tabline,

       wa_excel type alsmex_tabline.

 

data: it_header type standard table of ty_header,

       wa_header type ty_header,

       it_item type standard table of ty_item,

       wa_item type ty_item.

data: gv_extnr type extnr.

data: bdcdata type  bdcdata occurs 0 with header line.

data: it_msg type standard table of bdcmsgcoll,

       wa_msg type bdcmsgcoll.

data: message(120) type c.

 

data: menge(20) type c.

data: price(11) type c.

 

at selection-screen on value-request for p_file.

   call function 'F4_FILENAME'

     exporting

       program_name  = syst-cprog

       dynpro_number = syst-dynnr

*     FIELD_NAME    = 'P_FILE'

     importing

       file_name     = p_file.

 

 

start-of-selection.

 

   call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     exporting

       filename                      = p_file

       i_begin_col                   = beg_col

       i_begin_row                   = beg_row

       i_end_col                     = end_col

       i_end_row                     = end_row

     tables

       intern                        = it_excel

* EXCEPTIONS

*   INCONSISTENT_PARAMETERS       = 1

*   UPLOAD_OLE                    = 2

*   OTHERS                        = 3

             .

   if sy-subrc <> 0.

* Implement suitable error handling here

   endif.

   loop at it_excel into wa_excel.

     at new row.

       clear wa_excel.

       clear wa_item.

     endat.

     case wa_excel-col.

       when '0001'.

         wa_header-extnr = wa_excel-value.

 

       when '0002'.

         wa_header-ref_extnr = wa_excel-value.

 

       when '0003'.

         wa_header-meeht = wa_excel-value.

       when '0004'.

         wa_header-bukrs = wa_excel-value.

       when '0005'.

         wa_header-werks = wa_excel-value.

       when '0006'.

         wa_header-prctr = wa_excel-value.

       when '0007'.

          wa_header-kstar = wa_excel-value.

       when '0008'.

          wa_header-btgrp = wa_excel-value.

       when '0009'.

         wa_header-ktext = wa_excel-value.

       when '0010'.

         wa_header-ltext = wa_excel-value.

       when '0011'.

         wa_header-klvar = wa_excel-value.

       when '0012'.

         wa_header-menge = wa_excel-value.

       when '0013'.

         wa_item-typps = wa_excel-value.

       when '0014'.

         wa_item-herk2 = wa_excel-value.

       when '0015'.

         wa_item-herk3 = wa_excel-value.

       when '0016'.

         wa_item-menge = wa_excel-value.

       when '0017'.

         wa_item-meeht = wa_excel-value.

       when '0018'.

         wa_item-ltext = wa_excel-value.

       when '0019'.

         wa_item-lpreis = wa_excel-value.

       when '0020'.

         wa_item-lpeinh = wa_excel-value.

       when '0021'.

         wa_item-kstar = wa_excel-value.

          when '0022'.

         wa_item-lpreifx = wa_excel-value.

       when '0023'.

         wa_item-arbpl = wa_excel-value.

       when '0024'.

         wa_item-arbplwerk = wa_excel-value.

 

 

 

     endcase.

 

           at end of row.

           append wa_header to it_header.

           wa_item-extnr = wa_header-extnr.

           append wa_item to it_item.

           clear wa_header.

           clear wa_item.

           endat.

   endloop.

*perform open_group.

 

loop at it_header into wa_header.

 

   if wa_header-extnr ne gv_extnr.

   gv_extnr = wa_header-extnr.

   clear bdcdata.

   refresh bdcdata.

   perform bdc_dynpro      using 'SAPMK70B' '1000'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70B-EXTNR'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/00'.

   perform bdc_field       using 'RK70B-EXTNR'

                                 "'TEST-75'.

                                 wa_header-extnr.

   perform bdc_field       using 'RK70B-REF_EXTNR'

                                " 'test-1'.

                                wa_header-ref_extnr.

   perform bdc_field       using 'RK70B-KOKRS'

                                 '1111'.

   perform bdc_dynpro      using 'SAPMK70B' '1100'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70B-LTEXT'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/00'.

   perform bdc_field       using 'RK70B-MEEHT'

                                 "'m3'.

                                 wa_header-meeht.

    perform bdc_field      using 'RK70B-KSTAR'

                                 wa_header-kstar.

   perform bdc_field       using 'RK70B-BUKRS'

                                 "'1111'.

                                 wa_header-bukrs.

 

   perform bdc_field       using 'RK70B-BTGRP'

                                 wa_header-btgrp.

 

   perform bdc_field       using 'RK70B-WERKS'

                                 "'z001'.

                                 wa_header-werks.

   perform bdc_field       using 'RK70B-PRCTR'

                                 "'p001'.

                                 wa_header-prctr.

 

   perform bdc_field       using 'RK70B-KTEXT'

                                 "'TES"T7'.

                                 wa_header-ktext.

   perform bdc_field       using 'RK70B-LTEXT'

                                 "'TEST 6'.

                                 wa_header-ltext.

   perform bdc_dynpro      using 'SAPLKKEA' '1300'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70_KKEA-MENGE'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '=GOON'.

   perform bdc_field       using 'RK70_KKEA-KLVAR'

                                 "'pg'.

                                 wa_header-klvar.

 

   perform bdc_field       using 'RK70_KKEA-MENGE'

                                " '                  1'.

                                wa_header-menge.

 

   loop at it_item into wa_item where extnr eq wa_header-extnr.

*  PERFORM bdc_field       USING 'RK70_KKEA-EXTNR'

*                                'TEST-1'.

   perform bdc_dynpro      using 'SAPLKKDI' '1301'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70L-PRICE_MANUAL(01)'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '=PINS'.

*perform bdc_field       using 'RK70E-LST_SETNR'

*                              '    1'.

   perform bdc_field       using 'RK70L-PMARK(01)'

                                 'X'.

   perform bdc_dynpro      using 'SAPLKKDI' '1301'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70L-KSTAR(01)'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/00'.

*perform bdc_field       using 'RK70E-LST_SETNR'

*                              '    1'.

   if wa_item-typps eq 'M'.

   perform bdc_field       using 'RK70L-TYPPS(01)'

                                " 'm'.

                                wa_item-typps.

   perform bdc_field       using 'RK70L-HERK2(01)'

                                " '1'.

                                wa_item-herk2.

   perform bdc_field       using 'RK70L-HERK3(01)'

                                 "'z001'.

                                 wa_item-herk3.

   menge = wa_item-menge.

condense menge.

 

   perform bdc_field       using 'RK70L-MENGE(01)'

                                 "'                   1'.

                                 menge.

   perform bdc_field       using 'RK70L-LPREIFX(01)'

                                  wa_item-lpreifx.

   perform bdc_field       using  'RK70L-ARBPL(01)'

                                  wa_item-arbpl.

   perform bdc_field       using  'RK70L-ARBPLWERK(01)'

                                  wa_item-arbplwerk.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/00'.

 

 

 

 

else.

 

perform bdc_field       using 'RK70L-TYPPS(01)'

                                " 'm'.

                                wa_item-typps.

   perform bdc_field       using 'RK70L-HERK2(01)'

                                " '1'.

                                wa_item-herk2.

   perform bdc_field       using 'RK70L-HERK3(01)'

                                 "'z001'.

                                 wa_item-herk3.

   perform bdc_field       using 'BDC_OKCODE'

                                 '/00'.

 

 

menge = wa_item-menge.

condense menge.

 

   perform bdc_field       using 'RK70L-MENGE(01)'

                                 "'                   1'.

                                 menge.

   perform bdc_field       using 'RK70L-MEEHT(01)'

                                 "'bag'.

                                 wa_item-meeht.

   perform bdc_field       using 'RK70L-LTEXT(01)'

                                 "'Cement OPC  - 43 Grade'.

                                 wa_item-ltext.

    perform bdc_dynpro      using 'SAPLKKDI' '1301'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70L-KSTAR(01)'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '=SICH'.

   perform bdc_field       using 'BDC_OKCODE'

                               '/00'.

   price wa_item-lpreis.

   condense price.

   perform bdc_field       using 'RK70L-LPREIS(01)'

                                 "'              415.09'.

                                 price.

   perform bdc_field       using 'RK70L-LPEINH(01)'

                                " '     1'.

                                wa_item-lpeinh.

   perform bdc_field       using 'RK70L-KSTAR(01)'

                                 "'40100230'.

                                 wa_item-kstar.

 

    perform bdc_field       using 'RK70L-LPREIFX(01)'

                                  wa_item-lpreifx.

 

   endif.

   clear wa_item.

   endloop.

*perform bdc_dynpro      using 'SAPLKKDI' '1301'.

*perform bdc_field       using 'BDC_CURSOR'

*                              'RK70L-PRICE_MANUAL(01)'.

*perform bdc_field       using 'BDC_OKCODE'

*                              '=PINS'.

*perform bdc_field       using 'RK70E-LST_SETNR'

*                              '    1'.

*perform bdc_field       using 'RK70L-PMARK(01)'

*                              'X'.

*perform bdc_field       using 'RK70L-PMARK(02)'

*                              ''.

*perform bdc_dynpro      using 'SAPLKKDI' '1301'.

*perform bdc_field       using 'BDC_CURSOR'

*                              'RK70L-KSTAR(01)'.

*perform bdc_field       using 'BDC_OKCODE'

*                              '/00'.

*perform bdc_field       using 'RK70E-LST_SETNR'

*                              '    1'.

*perform bdc_field       using 'RK70L-TYPPS(01)'

*                              'm'.

*perform bdc_field       using 'RK70L-HERK2(01)'

*                              '1'.

*perform bdc_field       using 'RK70L-HERK3(01)'

*                              'z001'.

*perform bdc_field       using 'RK70L-MENGE(01)'

*                              '                   1'.

*perform bdc_field       using 'RK70L-MEEHT(01)'

*                              'bag'.

*perform bdc_field       using 'RK70L-LTEXT(01)'

*                              'Cement OPC  - 43 Grade'.

*perform bdc_field       using 'RK70L-LPREIS(01)'

*                              '               415.09'.

*perform bdc_field       using 'RK70L-LPEINH(01)'

*                              '     1'.

*perform bdc_field       using 'RK70L-KSTAR(01)'

*                              '40100230'.

   perform bdc_dynpro      using 'SAPLKKDI' '1301'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70L-KSTAR(01)'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '=SICH'.

*  PERFORM bdc_field       USING 'RK70E-LST_SETNR'

*                                '    1'.

   perform bdc_dynpro      using 'SAPMK70B' '1100'.

   perform bdc_field       using 'BDC_CURSOR'

                                 'RK70B-LTEXT'.

   perform bdc_field       using 'BDC_OKCODE'

                                 '=BUCH'.

*  PERFORM bdc_field       USING 'RK70B-KTEXT'

*                                'TEST7'.

*  PERFORM bdc_field       USING 'RK70B-LTEXT'

*                                'TEST 6'.

*perform bdc_transaction using 'KKE1'.

   call transaction 'KKE1' using bdcdata[] update 'S' mode 'A' messages into it_msg.

 

*perform close_group.

*ENDAT.

else.

   continue.

   endif.

   clear wa_header.

endloop.

 

 

loop at  it_msg into wa_msg.

   call function 'FORMAT_MESSAGE'

    exporting

      id              = wa_msg-msgid

      lang            = 'EN'

      no              = wa_msg-msgnr

      v1              = wa_msg-msgv1

      v2              = wa_msg-msgv2

      v3              = wa_msg-msgv3

      v4              = wa_msg-msgv4

    importing

      msg             = message

*   EXCEPTIONS

*     NOT_FOUND       = 1

*     OTHERS          = 2

             .

   if sy-subrc <> 0.

* Implement suitable error handling here

      if sy-tabix = 1.

     write:/ 'MESSAGE TYPE',

              sy-vline,

             'MESSAGE TEXT'.

     write:/ sy-uline.

     endif.

     write:/ wa_msg-msgtyp under 'MESSAGE TYPE', 14 sy-vlinemessage under 'MESSAGE TEXT'.

     write:/ space.

     write:/ sy-uline.

   endif.

 

 

endloop.

form bdc_dynpro using program dynpro.

   clear bdcdata.

   bdcdata-program  = program.

   bdcdata-dynpro   = dynpro.

   bdcdata-dynbegin = 'X'.

   append bdcdata.

endform.                    "bdc_dynpro

 

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

*        Insert field                                                  *

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

form bdc_field using fnam fval.

*  if fval <> nodata.

   clear bdcdata.

   bdcdata-fnam = fnam.

   bdcdata-fval = fval.

*IF FNAM EQ 'RK70L-MENGE(01)'.

*  CONDENSE  bdcdata-fval.

*ENDIF.

   append bdcdata.

*  endif.

endform.                    "bdc_field

Enhance LSMW Effectiveness using ABAP code

$
0
0

This document explains, how to apply the ABAP code to LSMW objects to meet the business requirements, Data Validations, Error Summary Report and to navigate through the LSMW transaction, and find the areas where we can write our own ABAP code detailed by an example.


1. Introduction


The LSM Workbench is an SAP tool that supports single or periodic data transfer from non-SAP to SAP system. The tool supports conversion of data of the legacy system in a convenient way. The data can then be imported into the SAP system via Standard Batch / Direct Input, Batch Input Recording, BAPI or IDOC Methods.


Many times there could be an instance to validate migrating data through coding.  This can be achieved through ABAP code in LSMW to enhance the functionality. This document explains how to apply the ABAP code to LSMW objects to meet the business requirements, Data Validations, Error summary report and how to navigate through the LSMW transaction to find the areas where we can write our own ABAP code by detailed example.

 

2. ABAP Coding areas inside LSMW


ABAP code can be inserted in two areas in the LSMW transaction.

  1. User-Defined Routines
  2. Field Mapping and Conversion Rules

 

 

The first area is the administration screen for user-defined routines. ABAP code that is written here is done so in the form of a subroutine, and can be reused by all LSMW objects within the project in which the user-defined routine was created. This is ideal for creating code that has the potential for being used by other objects within a project. For example

The second area in which we can insert ABAP code is in the maintain field mapping and conversion rules step of the LSMW. When ABAP code is inserted there, it applies only to objects in which it was inserted and cannot be reused by other objects. An example of this would be writing code that performs a specific data check applicable only to the Infotype for which the object was created.

2.1 View Processing areas

 

The processing areas (in Field Mapping and Conversion rules step) are not visible by default. We need to activate these areas by selecting the required processing area from Extras -> Layout option as shown below.

 

 

 

 

Now all the processing areas will available as shown below.


2.2 Events / Processing Areas


 

ABAP coding can be inserted at specific processing times.

 

 

Processing Area

Processing Time

Default setting

1

__GLOBAL_DATA__

like TOP INCLUDE, Here we can declare the variables, internal tables, constants etc.

(blank)

2

__BEGIN_OF_PROCESSING_

Before the beginning of data processing                             

(blank)

3

__BEGIN_OF_TRANSACTION_

Before the beginning of transaction data processing                       

(blank)

  1. 3.1
__BEGIN_OF_RECORD__Before applying the conversion rules for a source structureInitialize the structure  <segment> (Name of target structure)Batch Input, Direct Input:<segment> = init_<segment>.BAPI, IDoc:g_edidd_segnam = '...'.g_edidd_segnum = '....'.g_edidd_psgnum = '......'.g_edidd_hlevel = '..'.Clear <segment>.
  1. 3.2
__END_OF_RECORD_After applying the conversion rules for a source structure

Transfer_record.

4

__END_OF_TRANSACTION__

After finishing transaction processing                       

Transfer_transaction.

5

__END_OF_PROCESSING__

After finishing data processing                             

(blank)

 

 

2.3 Global Functions


The LSM Workbench provides a series of functions that can be used in any position of the ABAP coding.

 

Global function

Description

transfer_record.

Transfers the current record (i.e. for the current target structure) to the output buffer.

transfer_transaction.

Writes the current transaction to an output file. All records of the output buffer are transferred to the output file.

skip_record.

The current record is not transferred to the output buffer.

skip_transaction.

The current transaction is not written to the output file.

 

To insert Global function in coding, select Insert -> Global Function as shown below.

 

 

 

3. Example with Sample Code


Let’s take a simple example to change the employee First and Last Name. This is not a business requirement indeed, but, taking into consideration a simple scenario, for a better understanding, is explained in the following section. This example mainly will help you to write the custom code in LSMW.

 

This LSMW is to change the Employee’s First and Last Name in Infotype 0002 (Personal Data). Based on the Person ID, the program picks up the PERNR from the Infotype 0709 (considers multiple personnel numbers of the same employee, irrespective of the statuses i.e. Active, Inactive, Withdrawn and so on) and updates all PERNR's in the respective Infotype 0002 i.e. Employee’s First Name and Last Name.

 

Points to be taken into consideration:

 

  1. Validate whether the provided Person ID is valid i.e. the Person ID specified in the flat file exists in the system or not. This is handled in __BEGIN_OF_TRANSACTION__ processing block.
  2. If the Person ID is invalid, the record is sent to the error Internal Table and further process is skipped. This is also handled in __BEGIN_OF_TRANSACTION__ processing block. Then the Error Person ID's will be downloaded to a spread sheet once the conversion is done. This is handled in __END_OF_PROCESSING__ processing block.
  3. Based on the input data file Person ID, the program should pick up the PERNR/PERNR's from the Infotype 0709 and update all PERNR's. This is handled in __END_OF_RECORD__ processing block. This processing block is called for all available PERNR for the Person ID and additional records are inserted to output records LSMW buffer.

 

 

1. Maintain Object Attributes

 

 

2. Maintain Source Structures

 

 

3. Maintain Source Fields

 

 

Input File:

 

Assume USER01 exist in the system and valid, XYZXYZ is an invalid Person ID.


4. Maintain Structure Relations


 

5. Maintain Field Mapping and Conversion Rules

 

Select Change Mode.

 

 

Double click on __GLOBAL_DATA__ block, ABAP Editor will be opened. This is like TOP INCLUDE, declare the required variables, structures and internal tables here.


 

Double click on __BEGIN_OF_PROCESSING__ block (this block will trigger Convert data step execution once).  Declare Selection Screen related statements like Parameters, Select-options etc here. This will be appeared in Convert Data step selection screen.


 

Output:


 

Double click on __BEGIN_OF_TRANSACTION__ block (this block will trigger every new transaction, say for example if the input data file contains 10 records then 10 times this block will trigger).  Declare the Validation logic here.

 

SC20.jpg

 

Here the select query checks the Person ID is exist in the system or not. If it is not exist, error table is updated and the particular entry is skipped for further processing using skip_transaction global function. If it is exist, All PERNR's (Active, Inactive if any) against the Person ID will be stored in LT_PERNR table.

 

In every source structure __BEGIN_OF_RECORD__ and __END_OF_RECORD__ routines are available. These routines executes before and after the conversion rules at each structure level.  For eg, _end_of_record_ can be used to call ‘transfer_record' as many times as the particular structure is required to be inserted. This routine is used in many business cases like extend a Material to multiple plants etc.

 

 

 

 

Double click on __END_OF_RECORD__ block (this block will trigger after applying the conversion rules for a source structure).

The first transfer_record statement is default.  Here additional transfer_record statement is used to insert multiple records for the same Person ID's PERNR.

 

Double click on __END_OF_PROCESSING__ block (this block will trigger end of every new transaction). Write the code to download and display the error records as shown below.

 

 

6. Specify Files


 

7. Assign Files

 

 

8. Read Data


Execute the step to read the data from flat file.


9. Convert Data


Execute the step, here additional selection parameter ERR_PATH is available to select the error file download path (This is declared in _BEGIN_OF_PROCESSING__ block).


 

Execute


 

Screen shot of downloaded Excel file


 

 

10. Continue with the processing (Create batch input session and Run batch input Session) to update the valid PERNR's.

 

4. Debugging LSMW Code


We can debug LSMW object by putting a hard or soft breakpoint.

 

In Maintain Field Mapping and Conversion Rules, We can code BREAK-POINT at the very first field / where ever we need to debug. Then the program execution will break when it reaches there.

 

 

We can also put soft breakpoints in the system generated code. To view the generated code, select Display Conversion Program step and execute.


 

If this step is not visible, Go to Extras -> User Menu and activate.

 

Thanks,

Ramanathan Maniraman

Project Lead, SAP Practice

iGATE Global Solutions Ltd.


SERVICE MASTER UPLOAD Program Through BAPI With Long Text

$
0
0

Hi,

Its very important program for service master upload(MM module).

 

 

 

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

*                PROGRAM INFORMATION

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

*  PROGRAM....... ZMM_SERVICE_BAPI

*  TITLE......... SERVICE MASTER UPLOAD

*  AUTHOR........ SABYASACHI KARFORMA

* FUNCTIONAL....

* START DATE.... 23/07/2013

* END DATE.......23/07/2013

* DEV.CLASS......ZMM

* TCODE..........ZMM_SERVICE

*  R/3 RELEASE....SAP ECC 6.0

*  TRANSPORTNR...  AEDK900242

*  COPIED FROM... N/A

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

*                PROGRAM FUNCTION:

* This conversion program is to Upload SERVICE MASTER.

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

*  PROGRAM TYPE.. Executable

*  LOGICAL DB.... N/A

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

 

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

*                CHANGE HISTORY

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

*  DATE CHANGE... <Date of change written>

*  AUTHOR........ <Author name>

*  CHANGE DESCR.. <Description of change>

*  R/3 RELEASE... <Release>

*  TRANSPORTNR... <Transport number>

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

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

 

report zmm_service_bapi  no standard page heading .

 

****Data Declaration

tables : asmd, asmdt.

type-pools: truxs.

 

types : begin of ty_serv,

         asktx type asmdt-asktx,

         astyp type asmd-astyp,

         meins type asmd-meins,

         matkl type asmd-matkl,

         bklas type asmd-bklas,

         chgtext type asmd-chgtext,

         text(1000) type c,

         ser_no type asmd-ean11,

         end of ty_serv.

 

data  : line1 type tdline,

         line2 type tdline.

 

data : it_serv type bapisrv_asmd,

        ls_return like bapiret2 occurs 0 with header line.

data : header like thead,

        lines like tline occurs 0 with header line.

data : service like   bapisrv_asmd-service.

data : im_service_datax like   bapisrv_asmdx.

data : it_desc type table of bapisrv_asmdt with header line.

data : tab_serv type table of ty_serv with header line.

data : wa_serv type  ty_serv.

data : it_intern type alsmex_tabline occurs 0 with header line.

data : tab_text type table of bapisrv_text ,

        wa_text type bapisrv_text .

data : wasmd type asmd,

        wasmdt type asmdt.

 

***** Selection file from selection screen

 

selection-screen begin of block b1 with frame title t1.

selection-screen comment 30(30) lb2.

selection-screen begin of line.

selection-screen comment 5(30) lb1.

 

parameters : p_file type rlgrap-filename obligatory ,

              p_begcol type i default 1 no-display,

              p_begrow type i default 3 no-display,

              p_endcol type i default 8 no-display,

              p_endrow type i default 32000 no-display.

selection-screen end of line.

selection-screen end of block b1.

 

 

*****Initialization Event

 

initialization.

   lb1 = 'File Name for Service Upload'.

   format color 3.

   lb2 = 'FILE SHOULD BE IN EXCEL FORMAT'.

   format color off.

   t1 = 'Service Upload'.

 

******At selection Screen Event

 

at selection-screen on value-request for p_file.

   call function 'F4_FILENAME'

     exporting

       field_name = 'P_FILE'

     importing

       file_name  = p_file.

 

******Start-of-selection Event

 

 

start-of-selection.

   perform convert_text_itab.

 

   perform  upload_service.

 

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

*&      Form  UPLOAD_SERVICE

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

form upload_service .

   loop at tab_serv.

     clear it_serv.

     clear : line1 , line2.

     translate tab_serv-astyp to upper case.

     condense tab_serv-meins.

     translate tab_serv-meins to upper case.

     it_serv-matl_group = tab_serv-matkl.

 

     call function 'CONVERSION_EXIT_CUNIT_INPUT'

       exporting

         input                = tab_serv-meins

         language             = sy-langu

      importing

        output               = it_serv-base_uom .

 

 

*    IT_SERV-BASE_UOM   = TAB_SERV-MEINS.

     it_serv-serv_cat   = tab_serv-astyp.

     it_serv-val_class  = tab_serv-bklas.

     it_serv-chgtext = tab_serv-chgtext.

     it_serv-ean_upc = tab_serv-ser_no.

     clear it_desc.

     refresh it_desc.

 

     it_desc-language = 'E'.

     it_desc-short_text = tab_serv-asktx.

     append it_desc.

     clear ls_return.

     refresh ls_return.

 

 

     call function 'BAPI_SERVICE_CREATE'

       exporting

         im_service_data     = it_serv

         im_service_datax    = im_service_datax

       importing

         service             = service

       tables

         return              = ls_return

         service_description = it_desc.

 

 

     call function 'BAPI_TRANSACTION_COMMIT'

       exporting

         wait = 'X'.

 

     loop at ls_return.

 

       if ls_return-type = 'E'.

 

         write:/ 'Error:' ,ls_return-message ,'for SERVICES:' , tab_serv-asktx color 6.

       elseif ls_return-type = 'S'.

 

         write  : / 'SERVICE CREATED' , service color 5.

         call function 'BAPI_TRANSACTION_COMMIT'

           exporting

             wait = 'X'.

 

         clear ls_return.

       endif.

     endloop.

     if not service is initial.

       header-tdobject = 'ASMD'.

       header-tdname = service.

       header-tdid 'LTXT'.

       header-tdspras = sy-langu.

       lines-tdformat = '*'.

       lines-tdline = tab_serv-asktx.

       append lines.

 

 

 

       call function 'SAVE_TEXT'

         exporting

           header          = header

           savemode_direct = 'X'

         tables

           lines           = lines

         exceptions

           id              = 1

           language        = 2

           name            = 3

           object          = 4

           others          = 5.

       if sy-subrc <> 0.

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

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

       endif.

 

       call function 'COMMIT_TEXT'.

 

       if sy-subrc = 0.

         write : / 'update successfully'.

       endif.

       refresh : tab_text[] , ls_return[]  , lines[] , it_desc[].

       clear : header , it_serv , im_service_datax , service.

     endif.

   endloop.

 

 

 

endform.                    " UPLOAD_SERVICE

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

*&      Form  CONVERT_TEXT_ITAB

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

form convert_text_itab .

 

   call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     exporting

       filename    = p_file

       i_begin_col = p_begcol

       i_begin_row = p_begrow

       i_end_col   = p_endcol

       i_end_row   = p_endrow

     tables

       intern      = it_intern.

 

   if it_intern[] is not initial.

     data : lv_index type i.

     field-symbols <fs>.

*--- Sorting the internal table

     sort it_intern by row col.

     clear it_intern.

     loop at it_intern.

       move it_intern-col to lv_index.

*--- Assigning the each record to an internal table row

       assign component lv_index of structure tab_serv to <fs>.

*--- Asigning the field value to a field symbol

       move it_intern-value to <fs>.

       at end of row.

         append tab_serv.

         clear tab_serv.

       endat.

     endloop.

   else.

     write:/ 'Data doesnot present in Excel File' color 6.

   endif.

endform.                    "CONVERT_TEXT_ITAB

 

 

 

 

Regards

Sabyasachi Karforma

Image in Selection Screen

$
0
0

Image in Selection Screen

____________________________________________________________________________________

Author: Jogeswara Rao Kavala


 

Purpose:

To decorate the selection screen of a development with meaningful pictures.

 

Idea Background:

Often there is a lot of blank space left out in the selection screens of report programs. And these reports are more often Function specific or End-user category specific.

Hence, a thought to identify the program at the first glance itself with the respective function, gave rise to this idea. If we provide pleasant images related these respective functions in  Selection screens, they will look good and reduce the boredom from the monotonous screens.

Also we can have relevant captions / slogans on these pictures.

 

Here are few such screens.

zxyz.jpg

tyre.jpg


dt.jpg

zpm1.jpg

 

Sounds useful?  and want to have screens like this?

 

Here is how

This is done using the Docking Container either at the right or bottom of the screen.

 

1. Upload the image

Let's suppose the requirement is to have a picture in the Docking Container located at the bottom of the screen.

The approximate pixel size of the image required will be 1280 (W) X 370 (H)   (in case of PC with 1366 X 768 resolution)

(The size is about 650 X 580 in case the Docking Container is on the right)

Have the image on the desktop, (.jpg extn will do).

 

T-code: SMW0

smwo.JPG

 

Execute

smw0_1.JPG

 

Click on Create: Give name of the object (say XYZ) and description

Click on icon Import

Select the image on Desktop and click Open.

smw0_2.JPG

Now the image is available in the system for use.

 

 

2. Coding in your Report Program

 

Data Declaration:

 

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

*Data declaration for Docking Container

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

DATA:

   ok_code TYPE sy-ucomm,

   r_dock_container  TYPE REF TO cl_gui_docking_container,

   r_dock_container1  TYPE REF TO cl_gui_docking_container,

   htmlviewer TYPE REF TO cl_gui_html_viewer,

   r_grid  TYPE REF TO cl_gui_alv_grid,

   picture_control_1 TYPE REF TO cl_gui_picture,

   picture TYPE REF TO cl_gui_picture,

   url(256) TYPE c.

 

DATA: repid LIKE sy-repid.

DATA: file_name LIKE sapb-sapfiles,

       file_type LIKE bdn_con-mimetype.

 

 

 

At selection-screen output or Initialization

 

AT SELECTION-SCREEN OUTPUT.

* Create a Docking container and dock the control at right side of screen

   CHECK r_dock_container IS INITIAL.

 

   CREATE OBJECT r_dock_container

     EXPORTING

       repid                       = repid

       dynnr                       = sy-dynnr

       side                        = cl_gui_docking_container=>dock_at_bottom

       extension                   = 215

     EXCEPTIONS

       cntl_error                  = 1

       cntl_system_error           = 2

       create_error                = 3

       lifetime_error              = 4

       lifetime_dynpro_dynpro_link = 5

       OTHERS                      = 6.

 

   IF sy-subrc <> 0.

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

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

   ENDIF.                             


 

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

*&  Load the picture

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

   repid = sy-repid.

 

   IF htmlviewer IS INITIAL .

     CREATE OBJECT picture_control_1

       EXPORTING

         parent = r_dock_container.

   ENDIF.

 

   CHECK sy-subrc = 0.

   CALL METHOD picture_control_1->set_3d_border

     EXPORTING

       border = 0.

 

   CALL FUNCTION 'DP_PUBLISH_WWW_URL'

     EXPORTING

       objid    = 'XYZ'

       lifetime = 'T'

     IMPORTING

       url      = url

     EXCEPTIONS

       OTHERS   = 1.

 

* Load the picture by using the url generated by the data provider.

   IF sy-subrc = 0.

     CALL METHOD picture_control_1->load_picture_from_url_async

       EXPORTING

         url = url.

   ENDIF.

 


See the highlighted parts, in the code above,

The first one namely 'bottom' refers to the position of the Docking Container. (For position on right, this would be dock_at_right)

The second one '215' refers to the Docking Container window extension, with reference to 0 at the bottom.

The third one 'XYZ' shows the picture Id we have just uploaded.

 

 

Now your selection screen is decorated with a picture.

 

Note:

The picture resolution varies as per the Desktop / PDA resolution.

So, it is advisable to try this on a machine which matches with the resolution of maximum number of machines in your area.

And also have a look at PCs with other resolutions, so that the selection fields are not covered by the Docking container.

The Docking Container is an adjustable window, so this can be dragged down or right as the case may be, to uncover selection fields, if at all this happens.

 

Jogeswara Rao K


SE03 - Transport organizer tools - Objects in request Part 1

$
0
0

As a beginner ,I was used to Tcodes - SE09 /SE10 to deal with transports and later I came to know that there is more to it , We just need to explore SAP.

 

SE03 - It is collection of programs which helps us to manage our transports .Transports can be a carrier which carries our development/data from one system to another .

 

 

However lets come back to SE03 ,I know it can be a BASIC thing for many of us but would try to share whatever I have learnt so far.

 

SE03 - Tcode:

 

1. Search for objects in Requests and tasks :

 

This one is very helpful if you want to verify the number of TRs being released or are being availlable in the development system as of today .

Apart from version mangement which is available for objects ,We can utilize this utility to find out when and who  created and released the TR.

 

Steps;

 

1. Go to SE03 - Search for objects in requests and tasks -> Execute

sdn33.png

It does have options to select - If we want a list of TR which has been used for a program -Say "ZTEST".

Just put it in the screen as given below and execute - It will give you a list of transports :

SDN44.png

 

I have seen in some occasion when we have a situation where functional configuration relevant transports need one.

Well SAP does have a option availbale for that - IMG activity -

sdn55.png

Choose the SPRO configuration step and execute - It will display the list of transports .

 

It does have a selection criteria on Transport creation /attributes etc .Choose accordingly .

sdn66.png

 

 

2.Analyze Objects in Requests/Tasks :

sdn77.png

 

It gives us an option to anlyse a particular transport and a report will displayed with package /layer details.

 

SDN99.png

 

Please press F4 and find the help.

 

sdn100.png

 

If you want details of non released TR - Please put the sub task of the TR .

If you want the details of released TR - You can put the primary one - It will give the details.

 

3.Include objects in a Transport request :

sdn1111.png

In development system - We used to develop objects ,Howevr while trying to move it to production - We want to ensure that all the developed objects are in a TR .

 

If not - We can use this feature to make it happen.Let me agree to the fact that SAP does prompt for TR while we create a object in a package but if in case you need some existing object to be moved along with TR or any other scenario which might need to include a object in a TR.We can use it.

 

Ex:

 

Table ZTEST created by me needs to be included in some TR .

sdn1222.png

 

After executing it will ask for inlcluding the object in a TR ;

 

sdn33333.png

 

I hope this document will help someone .

 

Thanks - Boby

Automatic Creation of a Product Catalog Layout in SAP through ABAP report

$
0
0

Product Catalogs in SAP can be created / changed manually via the transactions WWM1/WWM2 and displayed through WWM3.

However there is no direct function module or BAPI available in SAP to create /change the layout of an existing product catalog.

 

Just to give an idea about what a product catalog looks like I am posting some screenshots of both the header information and the layout information of a catalog.

The first screenshot shows the header/basic data of a product catalog which primarily consists of the customer, sales area information, currency and variants (which again consists of id, language and currency ).

screenshot 1.png

The second screenshot dispalys the layout area which has several nodes in a hierarchical fashion and the last node in a hierarchy contains the actual material information.

screenshot 2.png

 

Here the two nodes refer to a particular brand and product line of that brand .The last node (product line) actually contains the material information.

screenshot 3.png

The Texts checkbox is ticked which indicates that the layout area item has texts maintains which again can be seen from the “Texts” tab (second tab to the left on the upper echelon).

screenshot 4.png

Automatic creation/change of a product catalog layout through an ABAP report involves the use of several function modules clubbed together . The ABAP report can have the customer number and the reference catalog id(whose layout needs to be changed, here it is TEST_CAT1 in the example screenshot shown above) as selection screen parameters. The process of layout creation/change is a repetitive one once you get hold of the basic principle.

There are primarily five database tables involved in the layout creation :TWGV(Layout) , TWGLV(Layout Area) , TWGLVT(Layout Description) , WLBM (Layout Area Item)  and WLMT (Texts for Layout Area Item).

 

In order to create a layout of an empty catalog (which only has the basic information but no layout area nodes) or to change an existing layout of a catalog (there are nodes in the layout but they need to be changed) the process that needs to be followed consists of the following simple steps:

  1. Read the catalog information (stored in database table WWMI) through a function module which will take as input the catalog id and return the entire catalog header information. We need the catalog information to determine the layout number (each catalog has a unique layout number) as all successive operations will be done on the layout having this layout number.
  2. For each database table that will be affected, create an internal table(lt_table_new) with the data that needs to be populated in the layout and also an internal table(lt_table_old) with the data which at present exists in the layout (this may be blank , incase if the layout is empty) .
  3. Check if the new entries need to be inserted/updated /deleted  in/to/from the existing layout via a function module which will then return three tables (lt_table_ins/lt_table/upd/lt_table_del) based on the action required.
  4. Save the entries in the database by calling another function module which takes as input the three internal tables created in step 2.
  5. Make the database changes reflect in the product catalog layout by calling another function module which takes as input the three internal tables and also a flag (indicator) which tells it the name of the database table whose changes it needs to pick up.

     

This principle needs to be followed for all the five database tables  that will be impacted:

  1. TWGV
  2. TWGLV
  3. TWGLVT
  4. WLBM
  5. WLMT

 

Now comes the list of the function modules (a simple debugging of transaction WWM2 will lead you to these)

 

The function module needed to achieve step 1 above is :  

ADV_MED_READ

 

Step 2 above needs the main population logic as it is used to create the internal table containing the layout data that we need to see in our layout ultimately. The old layout data can obviously be retrieved from the base by simple select statements.

 

The function modules needed to achieve step 3 above are as follows:

  1. TWGV_CHECK_CHANGE
  2. TWGLV_CHECK_CHANGE
  3. TWGLVT_CHECK_CHANGE
  4. WLBM_CHECK_CHANGE
  5. WLMT_CHECK_CHANGE

  The function modules needed to achieve step 4 above are as follows:  

  1. TWGV_SAVE
  2. TWGLV_ SAVE
  3. TWGLVT_ SAVE
  4. WLBM_ SAVE
  5. WLMT_ SAVE

The function module needed to achieve step 5 above is :

PRODCAT_CHANGE_DATA_PICK_UP

Following is a screenshot of code snippet showing the sequence of application of these function modules for table WLMT:

screenshot 5.png

screenshot 6.png

A similar process needs to be followed for all the other relevant database tables as well.

The PRODCAT_CHANGE_DATA_PICK_UP function module can to be used only once at the end to pick up all the data changes from all the various database tables and make them reflect in the product catalog.

These steps if followed will get you a nice looking catalog layout creation once your report is run

Attached is a sample code illustrating the process . Thanks for reading

Add a custom button to the ALV grid tool bar of CO27

$
0
0

This document helps you add a button on to the ALV grid toolbar of a standard report - CO27 Picking list.

 

-- The initial screen of ‘Picking list’ looks like this:

     screen0.jpg

 

-- On entering input and executing the report, it displays a list of order and material details as shown below :

     screen4.jpg

 

Follow the steps given below to achieve this :

 

(1) We will need to write code for button functionality in the method of “handle_toolbar_set” event as we are going to add it on to the toolbar.

     screen5.jpg

 

(2) Since it is a standard SAP program , we will check for implicit enhancements to add this code in the method shown above.

     screen6.jpg

 

     screen7.jpg

     There exists an implicit enhancement point in the method and we shall create one implementation.

 

(3) Create an enhancement implementation in the method of “handle_toolbar_set” event.

     screen8.jpg


(4) Name the implementation and enter the short text.

     screen9.jpg

 

(5) Write the code for adding a button on the toolbar.

     screen10.jpg

     In this example, we are adding a function code ‘ZBTN’ for the button and also naming it as “New Custom Button.”

 

(6) Activate the enhancement and run the report.

     screen12.jpg

     And this is it! We can see the new button that we have added on the toolbar.

     We have also assigned a function code for this to handle the action.

     On clicking this new button, the function code ‘ZBTN’ would be captured and the necessary logic be performed.

 

(7)  Handle the action on button click : We will write the logic for handling the user action in the method of “handler_after_user_command” event.

     screen13.jpg


(8) This method has handled user action for few of the buttons that are already in place.

     screen14.jpg

 

(9) We will follow the same process from step 2 to 5. Check for implicit enhancement points and create an implementation in this method.

     screen15.jpg

 

(10)  Write logic to perform the necessary action on button click.

     screen16.jpg

     We are calling this BADI to get the user command. By checking for its value, we are writing code in the ‘handle_new_custom_button’ subroutine.


Viewing all 935 articles
Browse latest View live


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