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

ABAP Reports on Web UI

$
0
0
ABAP Reports Links on Web UI
Introduction
One of the most common requirements especially when the client is using SAP CRM is the ability to execute ABAP Reports on the Web UI screen.
The purpose of the document is to brief on the step-by-step approach to achieve the above requirement.
The Custom Reports can be made available on the Web UI screen:
  • Through a Direct Link
  • Creating a new Work center
1.0 Logical System Mapping:

This the first step in achieving our requirement.
Before using the Transaction Launcher, SAP ITS (Internet Transaction Server) has to be configured with or without local ITS. The scope of the current document is only setting up SAP ITS using Local ITS.
  1. Go to TCode: CRMS_IC_CROSS_SYS
  2. Enter Mapping & Logical System Name
    • Logical System Name - System in which the GUI transactions have to be executed on Web UI
    • Please check if the authorization to change the entries in Production is existing. Else,
      • the entries has to be made for Production System and transported
      • Configure Transaction Launcher in Quality & Production environment (not recommended)
  3. Set 'Local ITS' checkbox
pic1.jpg
Create BOR Object (SE80)
  1. Copy Standard BOR Object TSTC
pic2.jpg
   2. For the newly created BOR
    • Under Method EXECUTE: Set 'Synchronous'
              pic3.jpg
       3. Change to status of the object to 'Implemented' (EDIT)
       4. Generate the object
    pic8.jpg
    Transaction Launcher

     

         1. Start the Transaction Launcher wizard using the below path

        

    SAP IMG > Customer Relationship Management>UI Framework>Technical Role definition>Transaction Launcher>Configure Transaction Launcher

        

         2. Give a name to the Transaction Launcher ID
                   pic5.jpg
         3. Give a Description & CLASS Name
      • The new Class will be created

                   pic6.jpg

         4. Select the values

      • Transaction type : BOR
      • Logical System
      • BOR Object Type: BOR object copied from TSTC
      • Method Name: EXECUTE

     

                   pic7.jpg

     

    Direct Link on the Screen

     

    Go to Navigation Bar: 

    Create the Links for the Navigation: (TCODE: CRMC_UI_NBLINKS) 

    Define Logical Links:

     Type: Launch Transaction

     Target ID: EXECLTX 

    Parameter: Transaction Launcher ID

     Parameter Class: CL_CRM_UI_LTX_NAVBAR_PARAM

     Title: Title of the Link  Description

     

    2.0.2. Create Direct Link Group  Create new Direct Link Group 2.0.3. Assign the Logical Link to the Direct Link Group 2.0.4. Assign the new Direct Link Group to the Navigation Bar Profile                           

    2.0.5. Define Business Role:             

    Select the Business Role and double click on 'Adjust Direct Link Group' 

    Select the Direct Link Group created in the previous step and double click on 'Adjust Direct Links'

     Set the 'Visible' checkbox and Save.

    The link will be visible on the Navigation Part in the Web UI Screen.      

        2.1. New Work Center To create a new custom work center, a new Z* Component has to be created and modified.

    2.1.1. Create a new BSP Component 

    Create a new Z* Component (TCODE: BSP_WD_CMPWB) or copy from a standard component. 

    Refer Standard Components WCC_AI_CM or WCC_SLS_CYC

    2.1.2. Create an Overview Page

    2.1.3. Go to Runtime repository Editor 

    Add View under the Window 

    Select the Overview Page created in the previous step 

    Create an Inbound Plug 'DEFAULT' 

    Right click on Component Interface & Add Interface View:

     Select the MainWindow (Inbound plug created & View added in the previous step) as the Interface View

     Add Component Usage and give a name (e.g. Reports) 

    Add Interface View to the Component usage created

    Used Component: CRMCMP_GS_WC

    Interface View: IFVGroupLinks

     Right-Click on ViewSets and add View Set 

    Select the Overview Page 

    Right-click on the viewset and add the View Area

     Right-click on the View Area and select the Component Usage added in the previous step (Reports.IFVGroupLInks).

     

    2.1.4. WD_USAGE_INITIALIZE: 

    Enhance / Modify the code in the Component Controller method WD_USAGE_INITIALIZE:

    2.1.5. Configuration of the Overview Page: 

    Go to the Configuration tab of the Overview Page created: 

    Select the Component & move it to the required columns & give a appropriate name:

     

    2.1.6. Header Description: 

    To get the Header on the Web UI screen after navigating to the Work Center created: 

    Enhance the following method: 

    Populate the value into the variable 'DESCRIPTION':

    2.1.7. Work Area Component Repository 

    Go to the following path & add the new Component created 

    Go to 'New Entries' & Add the new Component and the Window Name 

    Select the new entry & click on 'Inbound Plug Definition' 

    Enter a name for Target ID & the Inbound Plug 'DEFAULT' created under the Interface view in the Component

     

    2.1.8. Go to the Navigation Bar Profile (TCODE: CRMC_UI_NBLINKS) 

    Create a new Logical Link: 

    LogLink ID: 

    Type: Work center 

    Target ID: Created in the previous steps 

    Define Work center Link Groups: 

    Select the Work Center link group & click on 'Assign Links to Work Center Link Group' 

    The Links created (using Transaction Launcher) for each Reports will be available under this Work Center Group 

    Assign the Logical Links (of type Launch Transaction) defined in the previous steps 

    Define Work Center 

    Assign the Work Center Link Groups to the Work Center:

    2.1.9. Assign the Work Center to the Navigation Bar Profile as required:

    2.1.10. Adjust the Links for the Business Role: 

    Select the Business Role * Click on 'Adjust Work Centers': 

    Ensure that the work center created is not 'Inactive': 

    Go to 'Adjust Work Center group Links' and ensure that the 'Visible' is checked: 

    If the requirement includes to provide a menu list on the Work center, check 'Menu':

     

    2.1.11. CRM Home Page 

    Go to the CRM Home Page & select the Business Role to which the links have been assigned: 

    New Work Center 'Reports' will be available with the 'Menu' option 

    Go to 'Reports' work center: 

    The links to the ABAP Reports will be available:


    The case of CL_HTTP_CLIENT & CL_IXML

    $
    0
    0

    Recently there were some mentions of getting XML using regular http requests in contrast to SOAP ( http://en.wikipedia.org/wiki/SOAP ) .

     

    On the web or intranet there are many XML resources that can be consumed using any http client .

     

    Those resources can be a simple links like this:

    http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

    or

    Web Services that can be consumed using regular http requests like this:

    http://www.webservicex.net//globalweather.asmx/GetCitiesByCountry?CountryName=United%Kingdom


    In program Y_R_EITAN_TEST_40_05 (attached) I demonstrate a program that use
    http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml .

    screenshot_02.png

     

    The main tools in this program are:

    - CL_HTTP_CLIENT : get the XML from the server .
    - CL_IXML : Parse the xml .

     

    The result of those is an internal table that is presented using cl_salv_table .

     

    The program assume that you need a proxy to get to the server so please enter your proxy info .

     

    screenshot_03.png

     

    screenshot_04.png

     

    Have fun.

    Useful feature of new ABAP debugging editor – Debugger Layer

    $
    0
    0

    Hello, sure has ever happened to us all that we have lost much time trying to locate a certain point process in SAP standard code where custom code is

    implemented either through a routine (user-exit, cmod, badi o enhancement)

     

    There is a functionality in the new debugger that allows us to navigate through the stack and stop at code points depending on certain conditions.

     

    Custom code will always be in any of the packages area of customer names eg Z*

     

    This tool named Debugger Layer has a filter per package.

     

    The first is to change to the new editor if you have the old set.

    imagen1.png

     

    If you want to have set by default the new debugger must configure it from the menu Tx SE38

    imagen2.png

    imagen3.png

     

    We started throwing the debugger /H at the beginning of our process SAP

    imagen4.png

     

     

    We make sure that the debugger is active

    imagen5.png

     

    Press F8…opens the debugger

    imagen6.png

     

    First active Layer-Aware Debugger flag

     

    We can use Predefined Layer using Debugger Profile. To create or maintain, go transaction SLAD.

     

    But in our case, we only need to break in custom packages, we use the filter package.

    imagen7.png

     

    We will use these flags if you want to stop the entry and/or exit of our custom code

    imagen8.png

     

    If you want to reuse the same filter in the future we can record it, otherwise just press ok.

      imagen9.png

     

    We can see that we select Profile Active.  At any time we can disable it.

    imagen10.bmp.png

     

    and turn it back on by pressing the button

    imagen11.bmp.png

     

    Press the Next Object Set button to navigate to the following custom code that belongs to any of the packages listed in the filter associated with the profile

    imagen12.bmp.png

     

    The debugger stopped at a custom function that belongs to a custom package

    imagen14.bmp.png.bmp.png

     

    In this case it was the BTE 1650 customized where the system allows us to perform additional searches in the process of G/L Account Line Item Display

    imagen13.png

     

    I think it's a very useful tool for programmers.

    Encryption and Decryption Algorithm using class :CL_HARD_WIRED_ENCRYPTOR

    $
    0
    0

    Introduction:

    This document gives brief idea on the encryption and decryption methodology used for encrypting text.

    We are using Class CL_HARD_WIRED_ENCRYPTOR.


    Note:

    1)The Method used of this class for Encryption is - ENCRYPT_STRING2STRING.

    2)The Method used of this class for Decryption is - DECRYPT_STRING2STRING.


    Class- CL_HARD_WIRED_ENCRYPTOR:

    This class is used to encrypt/decrypt a string/xstring data using hard-wired encryption/decryption algorithm.

    Steps:


      1) Below screen shows the view of methods in class-CL_HARD_WIRED_ENCRYPTOR Class.

           This class uses ‘UTF_8’ encoding.

           It also uses base64 algorithm for encryption and decryption.

    Initial_screen.PNG


     

    Find an SAP Enhancement from source code

    $
    0
    0

    In this document indicates how to find an SAP enhancement from source code.

     

    First we start the process in debugging mode by using the /H command.

     

    AMPLIACION0.png

     

    Once in debugging mode will introduce this break-point statement CALL CUSTOMER-FUNCTION

     

    AMPLIACION01.png

    AMPLIACION001.png

     

    Navigate through the various calls to find what is useful to us.

     

    AMPLIACION2.png

     

    We look at the source code line where the call is CALL CUSTOMER-FUNCTION

    AMPLIACION4.png

     

    We double-click to Navigate us to FM

    AMPLIACION5.png

     

    To know the related enhancement go to transaction SMOD

    AMPLIACION6.png

     

    Open the Matchcode and press INFORMATION SYSTEM button.

    AMPLIACION7.png

     

    Press ALL SELECTIONS button and will filter through the field with NAME COMPONENT.

    AMPLIACION8.png

     

     

    We introduce the FM in this field and we found the enhancement to which it is assigned.

    AMPLIACION9.png

    AMPLIACION10.png

     

    With this enhancement, we can now go to the TX CMOD, create our Z project and use this enhancement.

    AMPLIACION11.png

     

    I hope it is useful.

    Why Date format is YYYYDDMM

    $
    0
    0

    As a beginner in ABAP we have always curiosity to know the reason for something

    unusual . Once such curiosity is to know why date format is YYYYMMDD . We

    have always used date as DD.MM.YYYY format. So for what reason SAP system

    uses date as YYYYMMDD format . This phenomenon will be explained below with

    proper example.

    Suppose we uses date in format DD.MM.YYYY , so for this we will use data format

    as C(10) .

    Data lv_date type c(10) value ’10.12.2014’ .

    Data lv_date1 type c(10) value ’20.09.2014’ .

    Suppose above two date are stored in some internal table and we are required to sort

    the internal table by date in ascending order . Guess ! what will be the result .

    Since 10.12.2014 GT 20.09.2014 .

    However if we store this in char (10). It will be treated as character, so sorting will be

    done character by character and as we know 20092014 GT 10122014, so we will get

    Result

    20.09.2014 GT 10.12.2014 which is wrong !!!!

    So if we store date in YYYYMMDD format which is Numeric(8) , Sorting result will

    always come proper .

    In above example .

    Lv_date = 20141210

    Lv_date1 = 20140920

    So lv_date1 GT lv_date i.e.

    10.12.2014 GT 20.09.2014

    Configuring HTTP Content Server (1) - Creation of the Content Repository

    $
    0
    0

    Creation of the content repository

     

    A content repository is like a directory. It's a place were you could put several kind of data. You could use only one content repository to store all your data. You could use several content repository to be able to move it to another content server, for size issue, ...

     

    Transaction OAM1

    This is the global transaction where you will find all the customizing of the content server.

    oam1.png

     

    Go in the menu :

    oam1.png

    you could access directly using the transaction OAC0.

     

    oam1.png

    Press the button create (blank page), and press "Full administration"

     

    oam1.png

    First, set a name of content repository on two digits (you will have problems in some customizing of ArchivLink if you set more)

    Set the version (should be 0046)

    Set the host or the IP address of the content server

    Set the port number (should be 1090)

    Set the HTTP Script (should be ContentServer/ContentServer.dll)

    Set the OutputDevice to "ARCH"

     

    and save it

     

    You have create the content repository in the ECC system, not in the Content Server.

     

    Now, you could press the button "CS Admin"

    oam1.png

    When you use MaxDB, you have to set the setting for the driver.

    And press the SAVE button

     

    A new tab will appear

    oam1.png

     

    Now we will have to generate the certificat, go in the certificat tab:

    oam1.png

     

    Press the SEND button send.png

    Select the new line that appears and press the button activate send.png

     

    Now the Content server is ready

    send.png

     

     

     

     

     

    Check if the server is Up and Running

     

     

    First, you could check quickly using your internet browser :

    http://my_content_server_host:1090/ContentServer/ContentServer.dll?serverInfo

    (special thanks to Yann to remember me this helpful link)

     

    This link must display a list of variables like this :

    send.png

     

    One of this variable gives you the status : serverStatus="running";

    You could see also there is one ContentRepository : Z1

     

     

    The second method is to run the report : RSCMST

     

    Enter you ContentRepository and press F8

    send.png

     

    You must run all the steps of this report :

    send.png

    if you have any problem on your HTTP Content Server, launch this report to have informations on the errors.

    How to achieve material number as mandatory in MM Request For Quotation(ME41/ME42)

    $
    0
    0

    High level requirement : Whenever MM RFQ created the line item material column should me mandatory based on Doc. Type and Purchase Organization.

     

    Possible Solution : In SPRO customizing, define screen layout level we can set whether Reqd.entry / Opt. entry /  Display.

     

    Analysis :

    1)  In selection group basic item data we couldnt find Material field so its controlled by program level.

     

    "Field Label                    Reqd.entry  Opt. entry  Display

    Plant

    Storage location

    Indicator: "Texts exist"

    Short text

    Material group

    Material description

    Manufacturer part number"

     

    2) Tried to put validation on enhancement 'MM06E005' with PAI and Posting level but validation got triggered and stopping the entire process. Say like I have maintained 20 rows in table control with material column and 21st row i have maintained material text, in this case validation triggered but I couldnt delete since the error got triggered. Now there is an option to create from scratch RFQ from beginning which is redundant work.

     

    3) Tried BADI but not suitable.

     

    4) Tried field exit(EMATNR) based on Doc. Type and Purchase Organization. But the problem is when I maintain complete line items and validated successfully as our need but the field exit code got triggered on next row which is empty. I have tried to compare the Short Text field value but the value will be assigned to variable once field exit fired.

     

    Again I have created one more field exit on the data element 'TXZ01' and made small logic which is given below.

     

    Both field exit FM's(FIELD_EXIT_EMATNR and FIELD_EXIT_TXZ01) are grouped into one Function Group(ZFG_ME41)

    declared global variable as data gs_flag.

     

    Below the logic written inside FM-FIELD_EXIT_TXZ01

      IF SY-TCODE EQ 'ME41' or SY-TCODE EQ 'ME42'.

           if gs_flag is not initial and input is not initial.

             message 'Please enter material code' type 'E'.

           endif.

           clear gs_flag.

      ENDIF.

    Below the logic written inside FM-FIELD_EXIT_EMATNR

      IF SY-TCODE EQ 'ME41' or SY-TCODE EQ 'ME42'.

           if input is initial.

              gs_flag = 'X'.

           else.

              clear gs_flag.

           endif.

      ENDIF.

     

    Now I have tested both ME41/ME42 and its working as expected.

    This blog is very simple but I spent lot of time to achieve this validation and I can say 'everything is possible'.

     

    Please post your valuable comments and thanks for your valuable time.

     

    Regards,

    Vadamalai A,

    Technical Architect-Tech Mahindra.


    Object Finder Tool

    $
    0
    0

    Object finder Tool

    This tool is used to find the objects used inside an object and also it list all the objects within the dependent object of a given object. Along with, this tool also displays the TR associated with it.

    1. Example – PROGRAM à dependents objects à Objects of dependent objects à continues

    This tool can be used to get all the standard as well custom objects.

    Requirement:

    1.    To collect all the dependent objects of a program to transport to next environment. As many members work for a project where in each and every object is created by different persons, it sometimes becomes difficult to know all the dependent objects. In such cases, this tool would be helpful to achieve the goal.

    2.    If the dependent objects are known, then it is necessary to know whether the dependent objects needs to be transported or not. For this scenario, this tool helps us know the transport status thereby giving a clear idea whether to move the dependent object to next environment or not.

     

    Selection Screen:

    Selection screen comprises of the

     

    1.    OBJECT TYPE of the object and the OBJECT NAME, in question.

    2.    OBJECTS TO CONSIDER: The custom objects usually start with ‘Z’ or ‘Y’. A provision is given for the users to include the first letter of the custom objects to be included. ‘L’ is also included in this list as the FM starts with ‘L’.

    3.    UNRELEASED OBJECT ONLY CHECKBOX : Provision to list all the TR related to the objects or only the unreleased objects

     

    Output Layout:

     

     

                   First 2 columns indicate the selection criteria given.

                   Next 2 columnsindicates the objects used within an object and also it lists all the objects used within the dependent object.

                  4th and 5th cloumns indicate the called objects.

                  Remianing Clomuns indicates the TR details of the objects appearing in the BLUE MARKED COLUMNS

    a.    TR Request

    b.    TR Task

    c.    Date and Time of the DEV, QA and PRD systems

    d.    TR Status – RED indicates that it is in DEV, YELLOW indicates that it is in QA and GREEN indicates that is in PRD.

     

                     RED – in DEV, not in QA and PRD

    YELLOW – In DEV and QA and not in PRD
    GREEN – In DEV, QA and PRD

         

    Attached text file contains the code which can be created in any development system and can be used further.

    Run Time Error GETWA_NOT_ASSIGNED while accessing data from another stack program through Field symbol

    $
    0
    0

    Problem Description: Friends! I encountered one issue in my Project related to ABAP Dump GETWA_NOT_ASSIGNED. Actually we wrote one enhancement which triggered during creation of inspection lot via MIGO. This we wrote in customer exit EXIT_SAPLQPL1_002.

    When we tested this It worked Fine and changes were moved in Production without any issue.

     

    Problem occurred after 2 or 3 months when user tried to run MI07 (This Tcode also Triggers the same exit ) and faced some DUMP which says GETWA_NOT_ASSIGNED means Field symbol has not yet been assigned. At first sight it looks very simple that After assigning the field symbol we have to check if it was assigned successfully or not. I did the same but no hopes, dump was still there.

     

     

    DUMP was there at line number 79.

     

    Problem Cause :

     

    Here I want to fetch data from Stack program SAPLMBWL. Error analysis from ST22 says :

    You address a global function interface, although the

    respective function module is not active - that is, is

    not in the list of active calls. The list of active calls

    can be taken from this short dump.


    I checked the all stack loaded program , It contains SAPLMBWL in the list. All OK here also.

    I also tries TRY ENDTRY. But this exception is non-catchable.


    Problem Solution :


    Then I read above error analysis again and again and found that function module which contains IMSEG as parameter is not being called in the flow. So is that cause of issue... May be!!!

    then I tried following piece of code which test the parameters of function modules of SAPLMBWL.

     


     

    Guess what!! It worked.

    Here in above code first I am fetching complete stack using FM SYSTEM_CALLSTACK .

    And then checking if function module of global interface SAPLMBWL contains IMSEG as any parameter. If Yes the only I will assign this parameter.

     

    I couldn't get any other solution for this , That's why I am posting this Document, This may help you.

    Your valuable comments are welcome also please share If you have any other solution for this.

    GS-1 / EAN 128 barcode in Smartforms

    $
    0
    0

    GS-1 / EAN 128 barcode in Smartforms to be printed on all printer types; laser, zebra etc.

     

     

    Why

    When trying to gather information to print GS-1 / EAN 128 barcodes on smartforms I could not find a source with all the info. Sources on the internet only contained parts of the information needed, many weren't conclusive (SCN threads with status 'Unanswered' or at best 'Assumed answered').

    It took some trial and error to get a good result. To prevent others from having to invent the wheel again I want to share my gathered knowledge in this document.

     

     

    The steps

    To print GS-1 EAN128 barcodes in Smartforms we need to do the following;

     

    1) Create a system barcode font with new technology, Code128, Mode N. Mode N allows us to switch between the different subsets (A, B or C). By this we can end up with the most compact barcode. This system barcode should have the proper linear height settings so the barcodes are printed with the required height.

    gs1_1.JPG

    If a system barcode font as shown above is not available it needs to be created (SE73).

     

    In this example the system barcode named 'ZEAN128N' will be created;

    gs1_0.JPG

    gs1_11.JPG

    GS1_3.png

    GS1_4.png

    GS1_5.png

    GS1_6.png

     

    With the linear height settings the output height of the printed barcode is set. 765 corresponds to 32 mm.

    GS1_7.png

    GS1_8.png

     

    2) The system barcode font has to be added as a character format to the Smartstyle that will be used in the Smartform.

     

    • In this example Smartstyle 'Z_STYLE' is used (tcode SMARTSTYLES).

    gsss1.png

     

    • Character format 'GS' is created.

    gsss2.png

     

    • Our newly created system barcode font is used.

    gsss3.png

     

    • Activate the style.


    • Open the Smartform, in our example 'Z_FORM'.


    • Add the style to the Smartform.

    gsss4.png


    3) The code of form “STREAMLINE_BARCODE” has to be pasted in the “Form Routines” tab in the “Global Definitions” section. It is a form that converts the barcode string that is passed in, into a barcode that uses the best subsets (B or C) to make the smallest possible barcode.

     

    The code is in the attached file. I found it in a thread on SAPFANS.COM , thanks for that!

    GSFR1.png


    4) Call the form "STREAMLINE_BARCODE" of step 3 after the content for the barcode has been composed. The necessary switches to make the barcode recognizable as EAN128 and to make it as compact as possible are added.

     

    ( For preparing the content of the barcode: GS-1 / EAN128 content string for the barcode consist of an application indicator (AI) followed by the relevant application content, or a series of the two. So "<AI1><Content AI1>…..<AIn><Content AIn>" )

    gssst4.JPG.png

     

    At position A the variable gv_barcode_product_details-bc has the value:

     

    02871734435015037000000101518062810BATCH

     

    At position B the variable gv_barcode_product_details-bc has the value:

     

    >;>80287173443501503700000010151806281>60BATCH

     

     

    5) For displaying the barcode: A text node with the barcode field has to be added, using the character format defined in step 2 and the content prepared in step 4.

     

    gsst5.JPG

     

    By following these steps a proper GS-1 / EAN128 barcode should be created in the smartform.

     

    Tip 1: To check the barcode you can install a GS-1 app on your smartphone, for example the 'iGepir' app for IOS and android.

     

    Tip 2: You can scan the barcode from a print preview on the screen which saves you a lot of printing during testing. To do so go to the PDF preview of the print.

     

    Tip 3: For zebra label printer users with European languages: Only use the HELVE font for text since it is stored in the printer memory, others fonts will result in much larger print files with all the disadvantages that come with it.

    How to Add Watermark on each page of SAP Script Output

    $
    0
    0

    Hi,

     

    In this document i'll elaborate the process of printing the watermark in the SAP Script outputs. Though, there are few posts in SCN which will help for the same but the developers usually get stuck when it comes to print the same watermark on the NEXT Pages (after the First Page)

     

    1st, you need to upload the watermark image (BMP Format) in SAP using Txn Code SE78.

    In my case, I have used below Image as watermark:

    Not Approved.PNG

     

    Now, Once you have uploaded the image in SAP repository, you need to modify the Script Form & use this image as watermark during the output

     

    For instance, lets assume you need to print this watermark in case the Purchase Order is not yet released.

     

    To achieve this we follow below Steps :

     

    1. Go to SE71 & open the Script in Change mode :

    WM1.PNG

        2. Enter below line of code in the very beginning of MAIN Window :

     

    /*START Of Change by Bharat Bajaj for Watermark
    /:IF &EKKO-FRGKE& EQ 'S' AND &PAGE& EQ 1
    /:BITMAP 'ZMCG_NA_WMARK' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 100
    /:ENDIF
    /:NEW-WINDOW
    /*END Of Change by Bharat Bajaj for Watermark

     

    Here, the NEW-WINDOW command is to trigger a new window along with the main window which will hold the watermark image along with the Original Content of output. The Image is stored in SAP as ZMCG_NA_WMARK. You can give it any name & use the same in the script.

     

    WM2.PNG

     

    This part was to add the water mark on the First page & its quite easy & straight forward.

     

    Now, the Tricky part is to use the same watermark to be printed on subsequent pages for that Purchase order.

     

    For this, you need to perform below additional Steps :

     

    1. Create a Copy of Main Window in the FIRST Page :

              In the Page Window section of the form, Click on EDIT->Create Element -> MAIN Window. See below screenshots :

    wm3.png

    WM4.PNG

    WM5.PNG

     

    Please note that for the new Main Window ( MAIN 01 ) in the FIRST Page, you can keep the dimensions same as of (MAIN 00) or change it as per your output layout.

     

    Now, the tricky part is, in MAIN window, where to add the code to print the watermark, as the previous code will not work in this case.

     

    In my case, the water mark was required to be printed at the back of item header data, & thus, the code needs to be placed just in the beginning of the page element which prints the Item header (In my script form, the Element is ITEM_HEADER_F). You need to check your driver program or the script code to identify this element.

     

    Once Identified, you need to put below Code in MAIN Window at the Page Element like below:

     

    /EITEM_HEADER_F
    /*START Of Change by Bharat Bajaj for Watermark
    /:IF &EKKO-FRGKE& EQ 'S' AND &PAGE& GE 2
    /:BITMAP 'ZMCG_NA_WMARK' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 100
    /:NEW-WINDOW
    /:ENDIF
    /*END Of Change by Bharat Bajaj for Watermark
    /*                                                                       

     

    WM6.PNG

     

    Once this is done, save the form & activate it.

     

    Now open an unreleased PO & trigger the Print Preview and you'll see the watermark like below :

     

    PAGE 1 :

    WM8.PNG

    PAGE 2 :

     

    WM9.PNG

     

     

     

    As you can see above, the water appears on every page of the output.

    I hope this will be helpful for you.

     

    Regards,

    Bharat Bajaj

    About word wrap at coding

    $
    0
    0

    First, I think now the most common option to choose when you have to wrap your code is this one:

    (or almost the most common I've seen people are used to)

    6.png

    But let me say to you that there is another suitable option, that in my opinion is better.

    What this option does is, to keep the whole lines into the source code, and then

    to cut them at a position, the one that you've chosen.

    For example, here is the selection at first.

    2.png

    3.png

    Then, this result has the following effect:

    1.png

    Then, if we save the code, it's keeping and showing with this line larger than our expectations...

    So, we have to toggle to this option:

    4.png

    Then, the result is the following:

    5.png

     

    SO, briefly, this option keep the source code "as it", but the only thing is that it "truncates" the code,

    and to put it immediately at down first position.

    I think this option is better, because it keeps the source code unchanged, and then you can choose

    on which position is going to be better to be truncated.

     

    Hope it helps.

     

    Regards,

    Business Transaction Event for populating text in FI transaction

    $
    0
    0
    • Business Transaction Event are generally found in the Financial Accounting Module in SAP and is available from release 4.0 onwards.
    • A BTE has a predefined interface and allow us to attach additional functionality in the form of a service funtion module.
    • BTE can be used only as source code enhancement. We can’t use BTE for screen and Menu enhancement.
    • BTE are called at specific locations in the SAP object and the association of BTE to the FM is done via T code FIBF.
    • Every BTE has an interface defined by SAP which indicates the various parameters available for use. The interface exists using the naming convention
      ‘SAMPLE_INTERFACE_<BTE event>.
    • Custom BTE’s are created by copying the standard sample interface. The custom FM’s are then associated to the BTE using a product.

     

     

    How to find BTE: While executing SAP transaction, the program has to check which functions need to be called for that BTE. This is done by function module BF_FUNCTIONS_FIND. Put a break-point in the source code of function module, the value of the BTE can be found in variable I_EVENT.

           

    1st Requirement: To auto populate the text in Tcode FB01, FB60, FB70.

     

    Solution: The solution is driven by using the Business Transaction Events (BTE). A Function Module is written to populate the text whenever the BTE triggers.

     

     

    This solution will be reflected in T Code FB01, FB60, and FB70.

     

    Configuration steps

     

    1. Create a Product in Business Transaction Events(BTE):

     

       Go to FIBF transaction code > Settings in menu bar > Products > Customer > Create one product as ZPRODUCT and save.

    Capture.PNG

     

    2. Assign FM to the Product

     

    Go to FIBF transaction code > Settings in menu bar > Process Modules > of a customer >

    Capture.PNG


    3. Create a Custom function module by copying SAMPLE_PROCESS_00001120.

     

    4.Write the logic in the customized FM to populate the field as per requirement.

     

    We need to modify the structure T_BSEGSUB in order to populate the text.

     

    Write the logic as per your requirement in FM to display the text.

    Capture.PNG

     

     

    Once the FM is activated we can do the invoice posting through the respective T Code and the text will be updated in the document as shown below

     

    Capture.PNG

    Double click on the line item

    Capture.PNG

    2nd Requirement: To auto populate the long text of line items in TCode FB01, FB60, FB70.


    Solution:

    1. Create a Product in Business Transaction Events(BTE):

     

      Go to FIBF transaction code > Settings in menu bar > Products > Customer > Create one product as ZTEXT and save.

    Capture.PNG

     

    2. Go to FIBF transaction code > Settings in menu bar > Products > P/S Modules > of a customer > Create one product as ZTEXT and save.

    Capture.PNG

    3.Create a Custom function module by copying SAMPLE_INTERFACE_00001030.

     

    4. Below is the sample code written in the customized FM to update the long text.



    Capture.PNG

      

           .

    5. Once coding is done we can do the invoice posting to check the long text

    Capture.PNG

     

    Capture.PNG

     

    Long text is updated as shown below

    Capture.PNG

    Raw Material Where Used List.

    $
    0
    0

    Where Used List

    Of

    Raw Materials



    Target readers

    Sap ABAP Consultants, SAP Functional Consultants



    Keywords

    SAP ABAP, SAP SD.



    Table of Contents

    1. Introduction 
    2. Requirement
      • Report Screens & Output

      3. Selection Logic

      4. BOM explosion

      5. Display Report Output



    1.Introduction

    The Raw Material Where Used List is a report which was conceptualized from the requirements arising out of many clients wherein it is needed to find out all the finished products or semi-finished products, in which a particular raw material is used.

    In Standard SAP system, transaction CS15 is available for the same but CS15 can be used for reporting the data only for one material at a time.

    Standard SAP system doesn't provide any transaction which can be executed for a selection of materials or for an entire plant.

    After reading this document, one can create a report which will be used for multiple materials or entire plant to find out all the finished products or semi-finished products.

    This document provides a conceptual understanding for functional as well as for technical.


    2. Requirement

    The business requirement is to generate a list of finished or semi-finished goods in which a particular raw material has been used along with the quantity used. This report is reading the bill of materials (BOM) for the finished or semi-finished products to generate the report. Addition thing is, the multi-level BOM is read for the materials as well.


    In this section, a sample of report screens and report output is shown.

      • Selection Screen

                Selection Screen.PNG

      • Report Output

            Report Output.png

    This report development has three different sections:


      • First part, the selection logic has to be implemented that talks about how all the relevant master data details(to be used for report) will be fetched.
      • The second part of the logic involves exploding the bill of materials for all finished or semi-finished goods to read the raw materials in there and their respective quantities.     
      • Third part of the logic to display report showing Where Used List of Raw Material.


    3.Selection Logic

     

    In this part of the program, a list of finished and semi-finished goods is prepared for which the BOM explosion will be done.


             This list is prepared using two sets of logic as given below:         

      • When a material code is entered on the selection screen by the User
      • Material code has not been entered on the selection screen and user wants to execute the report at a plant


            CASE I - Material Code entered on the selection screen

            

    When a material code is entered on the selection screen by the User. Check if this material is a purchased material i.e. procurement type F. If yes, then follow the logic given in the below flow chart.

             Selection Logic.PNG

    As per above logic, first BOM is selected from Table STPO for all the material numbers entered on selection screen as shown in snapshot below. If BOM is found, then material number and Plant is fetched for all BOM numbers from table MAST.

          STPO Query BOM Item.PNG

    In the above Select Query on STPO table, all the BOM's are collected into internal table it_material for further usage.

    Once all the BOM's are collected, then get all the material and Plants for these BOM's from MAST table(Material to BOM Link).

           MAST Material to BOM.PNG

        

             CASE II - Material Code Not Entered On the selection screen


    In case a material code is not entered on the selection screen and user wants to execute the report at a plant level, thenread all active materials with procurement types E & X from table MARC to create a list of finished or semi-finished goods for the plant.

            

    Procurement Type:

    ‘E’ = In-house production.

    'F' = External procurement

    ‘X’ = Both procurement types


             MARC Select.PNG

    As per logic, If material number is not entered, the get the material number and plant from table MARC for procurement type (BESKZ) = 'E' or 'X'.

    The materials collected into the internal tables are further used to get the BOM herarchy for the materials.

           MARC Select Query.PNG

    4.BOM explosion (exploding the bill of materials)

     

    This section of the development is used to find out the components of the finished good or semi-finished material along with respective quantities. It has to be ensured in this step that the raw materials at all levels of BOM (in case of multi-level BOMs) have been enlisted and the quantities have been calculated accordingly.


    Logic as per below flow diagram should be followed. But there is another option of using Standard Function Module which is explained in below steps. We have given the overview of the logic in the flowchart which can be used but generally the standard function module mentioned below will be used.


             BOM Explosion Logic.PNG

     

    All this logic can also be implemented using a standard SAP function module “CS_BOM_EXPL_MAT_V2”.


    In order to find out the components of the finished good or semi-finished material, SAP standard function Module "CS_BOM_EXPL_MAT_V2" is used.

    Function BOM.PNG


    The above FM is called in each loop pass for each material to retrieve the hierarchy levels of BOM for the materials.

    To fetch the BOM level, few parameters which are required as input are:


                   1.) Calculate scrap quantity (AUMGB) as Blank.

                   2.) Application ID (CAPID) as 'PP01'.

                   3.) Validity date as (DATUV) as sy-datum.

                   4.) EHNDL as '1'.

                   5.) Required quantity (EMENG) as 'Qty entered in selection screen'.

                   6.) Multi-level explosion (MEHRA) as 'X'.

                   7.) Memory use (MMORY) as '1'.

                   8.) Material (MTNRV) as 'Material number'

                   9.) Plant (WERKS) as 'Plant'.


    After this FM is called the hierarchy for BOM Levels is stored into a table.

    After fetching the hierarchy of the BOM Levels for each material the quantities for the same materials in the hierarchy

    should be summed up as shown in Snapshot below:


    BOM Loop Logic.PNG

    5.Display BOM Explosion Report

        

    In the display section the output data is formatted into a report as per the requirements. Principally the report

    should be formatted on the raw material code column. An error log also needs to be collected for all issues with

    the master data.


    Below is the snapshot showing the RAW MATERIAL Where Used List:

    Final Raw Material List.PNG

    Raw Material 599998 T has four levels with different finished goods such as 599994 TEST Level 4, 599995 TEST

    Level 3, 599996 TEST Level 2, and 599997 TEST Level 1. Each Level has specified Quantity with it.


    There is an Error Log which contains those records (materials) which have Procurement Type as 'E' or 'X' when

    material is already entered in the Selection Screen.




    Usage of CDHDR and CDPOS tables in recording Header changes of delivery

    $
    0
    0

    Introduction

    Sometimes there is a requirement where we need to make some changes in delivery header through custom program but we need to update the change log of delivery for those changes.

    Like here we are discussing a case where we need to update the LIKP table of delivery header through ABAP code like deleting or changing some header field’s value. LIKP is a standard Sales and Distribution table available within R/3 SAP systems depending on the version and release level.

    As changes done directly in delivery header get reflected in Changes option of Environment tab of header. Our requirement is to achieve similar thing when changes are done through program code not in the delivery directly.

     

     

    STEPS:

    How updation of change log is done in SAP:

    The change log of delivery header is updated through CDHDR and CDPOS tables.

    1. e.g.Let’s take an outbound delivery 82342514 and make changes in it’s header.

     

    1.jpg

    Go to header in change mode.

    2.jpg

    Currently, the shipment reason maintained is ‘Complete Delevery Bl’.

    Let’s remove it.

    3.jpg

     

    And save the delivery.

    After saving the delivery, shipment reason (TRSPG) gets removed in LIKP.

     

    4.png

    Also, the updation in LIKP is followed by CDHDR and CDPOS tables updation.

    Following entries appear in tables CDHDR  and CDPOS.

    5.png

    7.png

     

     

    As we can see from above tables, all the data regarding the change we did is recorded in CDHDR table along with a ‘change number’ which is used for searching in CDPOS table for that particular change .The new value and old value are also specified in the CDPOS table.

    Since, these tables got updated , changes are also reflected in Change log of delivery.

    Go to Environment -> Changes in delivery’s header.

    9.jpg

     

    This thing we need to remember regarding changes done in master data that they get recorded in these two tables and can be used in custom reports or functionalities based on transactional change and master data change.

    As in this case, we have made change direct in delivery , so it’s getting reflected in these tables but in case we update it through custom code we need to update CDHDR and CDPOS tables also through our code.

    STEPS for updating CDHDR and CDPOS tables through custom program.

    1.    Before updating LIKP table in custom code, extract the old values of LIKP in a work area.

    2.    After updating LIKP, take the new values of LIKP for that particular vbeln in a work area.

    3.    Call Function module 'CHANGEDOCUMENT_OPEN' passing vbeln as object id, object class as 'LIEFERUNG'. Please note that proper object class needs to be specified. In this case it is 'LIEFERUNG' , since the object being discussed is delivery data.

    4.    Call function module ‘CHANGEDOCUMENT_SINGLE_CASE' passing tablename as LIKP, workarea_new as new values work area and workarea_old as old LIKP values work area.

    5.    Call function module 'CHANGEDOCUMENT_CLOSE' passing the values given below .This FM will  provide a change number LIKE  CDHDR-CHANGENR. This indicates that CDHDR and CDPOS tables are getting updated through these function modules along with change number.

    Summary: As we have updated these tables, we are able to update the change log of delivery through this.Reference code can be found in attached document.

     

    Easing the pain in TMS - using transports of copies

    $
    0
    0

    Maybe you know the problem - QA queue is full of old requests, nobody knows which one is relevant (sometimes the programmer isn't even working for your company any more). The answer is transport of copies! This way, you can test your programs in qa system without filling the qa queue with requests - when your program is working, you release the original request and import it in production.

     

    Educating programmers is the next step. But how about automation? SAP delivers BAdI CTS_REQUEST_CHECK with method CHECK_BEFORE_RELEASE - just implement it and you can do various checks before releasing requests. First you have to check the transport type - just use a case condition:

     

     CASE type.       WHEN 'K' OR 'W'.

    This way, only workbench and customizing requests are taken in account - the BAdI ignores everything else including tasks.

     

    Creating transport of copies

     

    First, you need a popup to decide whether changes are final:

     

     

     CALL FUNCTION 'POPUP_TO_CONFIRM'             EXPORTING               titlebar       = 'Final?'               text_question  = 'Are your developments final?'               text_button_1  = 'Final'(001)               text_button_2  = 'ToC'(002)             IMPORTING               answer         = lv_answer             EXCEPTIONS               text_not_found = 1               OTHERS         = 2.

     

    To create a new request, you can use FM TR_INSERT_REQUEST_WITH_TASKS:

     

     CALL FUNCTION 'TR_INSERT_REQUEST_WITH_TASKS'                 EXPORTING                   iv_type           = 'T'                   iv_text           = lv_new_text                   iv_owner          = owner                   iv_target         = tarsystem                 IMPORTING                   es_request_header = lv_request_header                   et_task_headers   = lv_task_headers                 EXCEPTIONS                   insert_failed     = 1                   enqueue_failed    = 2                   OTHERS            = 3.

     

    T stands for transport of copies, I create a new description with "[TvK] <old text>" to see which transport was created by BAdI. owner and tarsystem is taken from original request. Next step is to copy all objects:

     

     

    CALL FUNCTION 'TR_COPY_COMM'                   EXPORTING                     wi_dialog                = abap_false                     wi_trkorr_from           = request                     wi_trkorr_to             = lv_request_header-trkorr                     wi_without_documentation = abap_false                   EXCEPTIONS                     db_access_error          = 1                     trkorr_from_not_exist    = 2                     trkorr_to_is_repair      = 3                     trkorr_to_locked         = 4                     trkorr_to_not_exist      = 5                     trkorr_to_released       = 6                     user_not_owner           = 7                     no_authorization         = 8                     wrong_client             = 9                     wrong_category           = 10                     object_not_patchable     = 11                     OTHERS                   = 12.

     

    TR_COPY_COMM copies all objects in background.


    Releasing and importing the created transport

     

    Next step is to release your request, ignoring object locks:


     

     CALL FUNCTION 'TRINT_RELEASE_REQUEST'                     EXPORTING                       iv_trkorr                   = lv_request_header-trkorr                       iv_dialog                   = ' '                       iv_without_locking          = 'X'                     IMPORTING                       es_request                  = lv_request                       et_deleted_tasks            = lt_deleted_tasks                       et_messages                 = lt_messages                     EXCEPTIONS                       cts_initialization_failure  = 1                       enqueue_failed              = 2                       no_authorization            = 3                       invalid_request             = 4                       request_already_released    = 5                       repeat_too_early            = 6                       object_lock_error           = 7                       object_check_error          = 8                       docu_missing                = 9                       db_access_error             = 10                       action_aborted_by_user      = 11                       export_failed               = 12                       execute_objects_check       = 13                       release_in_bg_mode          = 14                       release_in_bg_mode_w_objchk = 15                       error_in_export_methods     = 16                       object_lang_error           = 17                       OTHERS                      = 18.

     

    Other standard FMs don't ignore object locks, so you need TRINT_RELEASE_REQUEST with the option iv_without_locking.


    Since adding to the target buffer can take some time, I advise to do a loop:


     DO 5 TIMES.                       CALL FUNCTION 'TRINT_GET_LOG_OVERVIEW'                         EXPORTING                           iv_request                = lv_request_header-trkorr                           iv_with_transport_targets = 'X'                         IMPORTING                           et_log_overview           = lt_log_overview.                       lv_check = 0.                       LOOP AT lt_log_overview INTO wa_log_overview WHERE sysnam = '<sys>' AND rc = 'W'.                       ENDLOOP.                       IF sy-subrc = 0.                         lv_check = 1.                       ENDIF.                       IF lv_check = 1.                         EXIT.                       ENDIF.                       WAIT UP TO 1 SECONDS.                     ENDDO.

    When everything is fine, you can import the created request:

     

     CALL FUNCTION 'TMS_MGR_IMPORT_TR_REQUEST'                         EXPORTING                           iv_system                  = 'Q01'                           iv_request                 = lv_request_header-trkorr                           iv_ignore_cvers            = 'X'                           iv_monitor                 = ' '                           iv_verbose                 = ' '                         IMPORTING                           ev_tp_ret_code             = lv_trretcode                           es_exception               = wa_exception                         EXCEPTIONS                           read_config_failed         = 1                           table_of_requests_is_empty = 2                           OTHERS                     = 3.


    Done!

    Creating a VPC with VPN access for running virtual appliances on AWS - the easy way

    $
    0
    0

    Do you want to deploy and run a virtual appliance like the ABAP on HANA developer edition on AWS in a secure way? One recommended option is using a virtual private cloud (VPC) with openVPN server for VPN access in a public subnet and running the SAP system in a private subnet (as depicted in the drawing below).

    VPC_openVPN.png

    Instead of creating all these AWS resources manually as described in my previous document, you can use AWS CloudFormation to create the whole stack automatically using a CloudFormation script. The attached CloudFormation script/template makes it a lot easier to setup a secure VPC stack with VPN access for your trial or developer edition.

     

    Remark: There are other options to set up a VPC with VPN access on AWS. This approach should serve as proposal for modest testing and evaluation purposes and the template can be modified to your needs. Moreover, the ID of the openVPN access server AMI changes frequently. Thus, if the creation of the openVPN server instance fails, please check in the AWS Marketplace whether the AMI ID in the CF template is still valid or has to be updated.

     

    Prerequisites


    There two prerequisites to successfully use this CloudFormation script (besides a valid AWS account):

    a) You need a valid EC2 key pair, which you can use to connect to your VPN server instance using SSH:

    To create a dedicated key pair, navigate to the EC2 dashboard > Network & Security > Key Pairs and hit the Create Key Pair button. Download the .pem file containing your private key.

    b) You have to subscribe to the openVPN access server on the AWS Marketplace (for free), in order to accept the terms and conditions of this AMI:

    Navigate to the AWS Marketplace and search for the openVPN access server. Select the current release, click on Manual Launch and hit the Accept Terms button. Now you are allowed to create an openVPN server instance programmatically.

     

    Generate your VPC stack

     

    Now it's time to automatically build your VPC with VPN server using AWS CloudFormation:

    1. In the AWS console navigate to the CloudFormation service and ensure that you selected the desired region (e.g. US East for the AS ABAP on SAP HANA developer edition).

    2. Hit the Create New Stack button and select the attached CloudFormation script as template using the Browse button (remove the .txt extension).

    3. Enter the desired template parameters, i.e. an existing EC2 key pair and (optionally) a CIDR block (IP filter) for limiting admin access to your openVPN server instance:

    CF_parameters.png

    4. Hit the Create button and wait until your entire VPC stack has been created:

    CF_create_stack.png

    Remark: You can also delete your whole VPC stack (all AWS resources) automatically if you don't need it anymore by selecting your CloudFormation template in the AWS console and hitting the Delete Stack button.

     

    After the automatic creation of your VPC stack you'll find the admin URL and the access URL of your openVPN server in the Outputs tab of the CloudFormation service:

    CF_output.png

    Deploy your virtual appliance and connect to your VPC

     

    As I already described the remaining steps (configuring the openVPN server, deploying the virtual appliance, connecting to your VPC) in my previous document, please proceed with these steps described in Section 3. I hope the option described above (using AWS CloudFormation) makes it easier and more convenient for you to build and define your own VPC stack for deploying virtual appliances in the cloud.

     

    Final remark: Please keep in mind, that your openVPN server instance will not be managed by SAP CAL (start, stop, terminate) together with your CAL instances. Directly use the AWS EC2 dashboard to start and stop your openVPN server.

    Sending multi-line SMS

    $
    0
    0

    Can we send SMS to a phone using ABAP?

    Yes we can.

    First we have to do the SMS configurations. SAP SMS Configurationwill let you know how to do configurations.

     

    Once you have done the configurations you can do the coding. Here a simple program to send SMS using ABAP.  SWN_TEST_SEND_SMS1 is also available as a standard program. Here you can send only single line SMS. If you want to send SMS with separate lines you have to pass the i_type as'RAW' when  create_document. That's it. If you have done the SMS configurations correctly, sending SMS is every easy and will be useful too.

     

    Here is the simple coding that I have written....

     

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

    *& Report  Z_SEND_SMS

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

    *&                DESC: Test program for sending sms notifications                        *

    *&  DEVELOPER: Rukshani

    *&                DATE: 13.09.2014

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

     

    REPORT  z_send_sms NO STANDARD PAGE HEADING.

     

    * INCLUDES ------------------------------------------------------------*

    * TABLES - SAP TABLES--------------------------------------------------*

    TABLES sscrfields.

     

    * INTERNAL TABLES------------------------------------------------------*

    DATA: it_note TYPE STANDARD TABLE OF txw_note,

                   wa_note LIKE LINE OF it_note.

     

    * FLAGS----------------------------------------------------------------*

    * VARIABLES------------------------------------------------------------*

     

    * SELECTION SCREEN

    SELECTION-SCREEN BEGIN OF BLOCK b1.

    PARAMETERS: p_addr TYPE ad_pagnmbr OBLIGATORY.        " Mobile number

    PARAMETERS: p_subj TYPE so_obj_des.                                        " Subject of sms

     

    SELECTION-SCREEN BEGIN OF LINE.                                           " Body of sms single-line/multi-line

    SELECTION-SCREEN COMMENT (33) FOR FIELD p_body.

    PARAMETERS: p_body TYPE  soli-line.

    SELECTION-SCREEN PUSHBUTTON 81(4) text-001 USER-COMMAND cli2 .

    SELECTION-SCREEN END OF LINE.

     

    SELECTION-SCREEN END   OF BLOCK b1.

     

    * INITIALIZATION-------------------------------------------------------*

     

    * AT SELECTION SCREEN--------------------------------------------------*

    AT SELECTION-SCREEN.

       IF sscrfields-ucomm = 'CLI2'.

         CALL FUNCTION 'TXW_TEXTNOTE_EDIT'

           TABLES

             t_txwnote = it_note.

       ENDIF.

     

    * TOP OF PAGE----------------------------------------------------------*

    * END OF PAGE----------------------------------------------------------*

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

    * AT USER-COMMAND------------------------------------------------------*

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

     

    END-OF-SELECTION.

       IF it_note[] IS INITIAL.

         APPEND p_body TO it_note.

       ENDIF.

     

       PERFORM send_sms TABLES it_note USING p_addr p_subj .

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

    *&      Form  SEND_SMS

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

    *       Send SMS

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

    *      -->P_IT_NOTE  SMS text

    *      -->P_ADDR  Mobile No

    *      -->P_SUBJ  Subject

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

    FORM SEND_SMS  TABLES   I_NOTE

                                         USING     I_NUMBER  I_SUBJECT.

     

    * Data definition

       DATA: lo_send_request TYPE REF TO cl_bcs,

             lo_document TYPE REF TO cl_document_bcs,

             lo_dockey TYPE soodk,

             lo_recipients TYPE bcsy_re,

             lo_bcs_exception TYPE REF TO cx_bcs,

             i_service TYPE ad_pagserv,

             i_recipient TYPE REF TO if_recipient_bcs,

             i_text TYPE soli_tab,

             wa_text TYPE soli_tab WITH HEADER LINE,

             i_length TYPE so_obj_len.

     

       LOOP AT i_note INTO wa_note.

         i_length = i_length + STRLEN( wa_note ).

         MOVE-CORRESPONDING wa_note TO wa_text.

         APPEND wa_text TO i_text.

       ENDLOOP.

     

     

       TRY.

    *   handle request

           lo_send_request = cl_bcs=>create_persistent( ).

     

    *   set 'send immediately' -> no send queue required

           lo_send_request->set_send_immediately( 'X' ).

     

    *   create document

           lo_document = cl_document_bcs=>create_document(

                         i_type          = 'RAW'

                         i_text           = i_text

                         i_language = sy-langu

                         i_subject     = i_subject

                         i_length      = i_length ).

     

    *   add document to send request

           CALL METHOD lo_send_request->set_document( lo_document ).

     

    *   document key

           lo_dockey-objtp = lo_document->get_doctp( ).

           lo_dockey-objyr = lo_document->get_docyr( ).

           lo_dockey-objno = lo_document->get_docno( ).

     

           TRY.

    *       create SMS/pager recipient

               CALL METHOD cl_cam_address_bcs=>create_sms_address

                 EXPORTING

                   i_service = i_service

                   i_number  = i_number

                 RECEIVING

                   result    = i_recipient.

     

    *       add recipient to send request

               CALL METHOD lo_send_request->add_recipient

                 EXPORTING

                   i_recipient = i_recipient.

     

             CATCH cx_address_bcs cx_send_req_bcs.

               MESSAGE e000(yv01) WITH 'Unable to add SMS address' i_number.

               EXIT.

           ENDTRY.

     

    *   add recipient with its respective attributes to send request

           CALL METHOD lo_send_request->add_recipient

             EXPORTING

               i_recipient = i_recipient

               i_express   = 'X'.

     

    *   check if document has recipients at all

           lo_recipients = lo_send_request->recipients( ).

           IF lo_recipients IS INITIAL.

             MESSAGE e040(swn).

             EXIT.

           ELSE.

    *     sms has been sent

             CALL METHOD lo_send_request->send( ).

             COMMIT WORK.

             MESSAGE s000(yv01) WITH 'SMS  has been sent to' i_number.

           ENDIF.

     

         CATCH cx_bcs INTO lo_bcs_exception.

    *   error messages

           MESSAGE e034(salert) WITH lo_bcs_exception->error_type.

           MESSAGE e041(salert) WITH i_number.

           EXIT.

       ENDTRY.

    ENDFORM.                    " SEND_SMS


    Thanks

    Linking of Attachment in SAP documents

    $
    0
    0

    The linking of attachments between SAP documents will be required in many business scenarios in SAP. But in this document, I have taken a scenario of cross company posting to explain this process. Let us go through this with an example,

     

    Generally, an accounting document (i.e. Accounts receivable document) will be generated when billing is done (T-code VF01). In cross company trading scenario, when this document is generated, there may arise a requirement to post a corresponding AP document (Account Payable) on the partner company code. Using workflow, AP documents in partner company code can be posted. But how to transfer the attachment from AR document to AP document posted in SAP. This document will explain this process.

     

    Below screen shot shows the AR document posted (in Company code – 0774) which is generated upon Billing. The attachment can also be seen along with the AR document. The trading partner company code for this Customer is 3277.

    1.png

     

    When this document is posted, workflow will be triggered to post the AP document and the transfer of attachment will happen.

     

    AP document posted in the partner company code 3277 along with attachment is given as example below. Here, if you notice, the attachment from AR document is transferred to the newly posted AP document.

    2.png

     

    The linking of this attachment between the documents involves two steps,

     

    1. Configuration of Document Type and linking the content repository in T-Codes – OAC2 and OAC3 respectively. Also, changing the setting for the message type in transaction NACE

       b. Coding part to do the linking of attachment

     

    1. Configuration of Document Type

     

    Step 1: Go to Transaction OAC2 and create a new document type as shown below. Here, the kind of attachment which we intend to transfer is PDF.

    3.png

     

    Step 2: Go to Transaction OAC3 and create a link for content repository. Here Billing document (VBRK) and Accounting document (BKPF) will be linked      with a test content repository ‘TN’. Here in this example, link table ‘TOA01’ is used.

    4.png

     

    Step 3: Go to transaction NACE and select the output type for this process is followed. In storage mode select “Print and Archive” and give the document      type that was created in transaction OAC2.

    5.png

     

    B. Coding – To link the attachment

     

     

    Please find the code which is added as attachment along with document. Please refer the code for the variables mentioned here.

     


    Step 1: Use the object key (BKPF-AWKEY) of the AR document to prepare source object W_OBJECT

     


    Step 2: Call FM 'ARCHIV_GET_CONNECTIONS' using source object key to get the attachment document link into internal table T_TOAV0.

     

     

    Step 3: Prepare target object W_BKPF_OBJECT (i.e. target AP document to which attachment link needs to be created). Here, we can use AP document’s object key (BKPF-AWKEY)

     

    Step 4: Call FM ‘ARCHIV_WORKFLOW_COMMIT' and pass the import parameters as shown below.

       6.png

         Done. Attachment will be transferred.


    Feedback and Suggestions to correct any mistakes or improve this document are most welcome

    Viewing all 935 articles
    Browse latest View live


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