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

Adding ad-hoc notes to production orders, purchase orders, etc. and reading them

$
0
0

Business Requirement:

 

Our customer need a way to append/add ad-hoc notes to production orders and then needed to be able to include those ad-hoc notes in reporting.

 

Solution:

 

Use GOS (Generic Object Services).  It is easily activated (see document http://scn.sap.com/doc/DOC-33485) and readily shows up out-of the box in most all of your common places that you would use it such as production orders, purchase orders, sales orders, etc.  In our case it was for the production order.  We worked with the user to show them how to add the ad=hoc note into the production order.  Then we wrote a snippet of code in order to retrieve the note.

 

Example:

1. Go into CO02 and enter in a production order number and press enter.

2. Click on the arrow that is on the services for object button on the left side of the screen just below the enter button at the top left of the screen.  Then choose Create ----> Create Note

pic1.png

3. Type in the title of the note and then type in the note itself.  Once finished click on the green check box and then click on save the production order.

pic2.png

4. To retrieve the notes programmatically and display onto a report here is the snippet of code.

 

DATA: lv_instid_b               TYPE                   sofolentil-doc_id,

           lv_note                     TYPE                   so_text255,

           lt_object_content     TYPE TABLE OF solistil,

           ls_object_content     TYPE                   solistil.

 

CLEAR: lv_instid_b.

SELECT SINGLE instid_b FROM srgbtbrel INTO lv_instid_b

     WHERE reltype    = 'NOTE'

           AND instid_a  = <Prod Order #>

           AND typeid_a = 'BUS2005'

           AND catid_a   = 'BO'.

IF sy-subrc = 0.

     CLEAR: lt_object_content[], ls_object_content.

     CALL FUNCTION 'SO_DOCUMENT_READ_API1'

          EXPORTING

               document_id          =     lv_instid_b

          TABLES

               object_content       =     lt_object_content

          EXCEPTIONS

               document_id_not_exist           =     1

               operation_no_authorization     =     2

               x_error                                     =     3

               OTHERS                                  =     4.

     IF sy-subrc = 0.

          CLEAR: lv_note.

          READ TABLE lt_object_content INTO ls_object_content INDEX 1.

          IF sy-subrc = 0.

               lv_note = ls_object_content-line.

          ENDIF.

     ENDIF.

ENDIF.

 

------------------

Of course this can be easily adaptable to other objects such as purchase orders which would be typeid_a = 'BUS2012' and instid_a = <Purchase Order #>.  You can get the typeid_a value from the standard list of business objects.

 

To find the business object for what you are looking for go to transaction SWO1 and click on the button "Business Object Repository" and then choose All object types and click on the green check mark.

pic3.pngpic4.png

Then just search for the object you are looking for.  An example is shown below for Production Orders.

pic5.png


MAINTAIN_BAPI method for Customer Upload

$
0
0

For DATA Conversion activity, the customer data upload is the base for the rest of the upload. The MAINTAIN_BAPI is very powerful method from class CMD_EI_API to create as well as for change the customer data.

 

Customer creation and maintenance can be performed by using the below method of class CMD_EI_API

 

  • MAINTAIN_BAPI()

pic1.png

 

This method has three import parameters as shown below,

pic2.png

IV_TEST_RUN parameter needs to be filed with ‘X’ to run in the Test mode.  IV_COLLECT_MESSAGE parameter needs to be filled with ‘X’ to collect the messages.

 

IS_MASTER_DATA parameter is the main structure for creating the customer as well as for changing the customer data.

 

Below tree structure shows the available components in the IS_MASTER_DATA parameter,

pic3.png

 

We will see the MANDATORY field in the aforementioned components for creation as well as for change.

 

a) HEADER:

 

In HEADER component, we have two fields.

 

  • OBJECT_INSTANCE and
  • OBJECT_TASK

 

pic4.jpg

 

Only for external customer number range, KUNNR needs to be filled under OBJECT_INSTANCE

 

OBJECT_TASK has two indicators,

 

  • INSERT – I

 

  • UPDATE – U

 

 

If it’s for customer creation, then choose the indicator as ‘I’ and for customer change, it should be ‘U’

 

b) CENTRAL_DATA

 

This component is exclusively for updating the Customer General Data. If the requirement is to create only general data, then the  CENTRAL_DATA componentshould be filledall MANDATORY fields.

 

It has following subcomponents for Customer General data,

 

pic5.jpg

To update the Customer Control Tab data, the CENTRAL component needs to be filled. For Address Tab, the ADDRESS component needs to be filled.

 

Based on the operation, the TASK field should be filled.  For example, If it’s for creating the customer, then the TASK field should  be filled with ‘I’.

 

To update the Comments field  in the Address tab, the REMARK component  should be filled. Since this field is text field, then Language Key needs to be filled based on the requirement.

 

For Payment Transactions tab, the BANKDETAILS component should be filled.

 

pic6.jpg

To update the communication details which is available in the Address tab, the COMMUNICATION component should be filled.

 

pic7.png

c) COMPANY_DATA

 

The COMPANY_DATA component is presented for updating the company code data. It has below two components,

pic8.png

 

The CURRENT_STATE is Optional field for creation as well as for change.

 

COMPANY

Under COMPANY, the below sub components are available,

pic9.png

 

The TASK field has two indicators as ‘I’ and ‘U’.

If it’s for company code data creation, then choose the indicator as ‘I’ and for company code data change, it should be ‘U’

 

The company code should be filled in the BURKS field. The DATA_KEY-BURKS and TAKS fields are MANDATORY for Company code data.

 

The DATA and DATAX components should be filled for Account Management tab, Payment Transactions tab, Insurance tab and correspondence tab except the Dunning data.

For Dunning data from  correspondence tab, the DUNNING component needs to be filled. For Withholding Tax, the WTAX_TYPE component should be filled.

 

 

d) SALES_DATA:

 

The SALES_DATA component is presented for updating the sales area data. It has below two components,

 

pic10.jpg

The CURRENT_STATE is Optional field for creation as well as for change.

 

SALES

 

The TASK field has two indicators as ‘I’ and ‘U’.

If it’s for sales data creation, then choose the indicator as ‘I’ and for sales data change, it should be ‘U’

pics.png

 

Under DATA_KEY, three key fields are available for Sales area data. The TASK and DATA_KEY are mandatory for Sales area data.

 

The DATA and DATAX components should be filled for Sales tab, Shipping tab, billing document tab except for Taxes details.

 

For Taxes, the TAX_IND component which is available in the CENTRAL_DATA component should be filled.

 

For Partner function, the FUNCTIONS component should be filled with Mandatory partner function.

pic11.png 

 

The partner functions should be filled for successful creation of customer. With the help of account group, the partner determination procedure can be identified.

By using the tpaer table w.r.t to partner determination procedure, the mandatory partner functions can be identified to update the customer successfully,

 

 

Output Parameters

 

It has four output parameters to show the status of the customer upload.

 

·         ES_MASTER_DATA_CORRECT         -      Total Customer Data Without Errors

·         ES_MESSAGE_CORRECT                    -      Error Indicator and System Messages for Data Without Errors

·         ES_MASTER_DATA_DEFECTIVE       -      Incorrect Total Customer Data

·         ES_MESSAGE_DEFECTIVE                  -      Error Indicator and System Messages for Incorrect Data

White Paper on 'Color Printing in SAP Scripts'

$
0
0

Abstract:

                  As we are aware, we can print the text in different colors as required in smartforms. It is easy to print the text in colors using the color feature in smart styles. Imagine there is a form, which is developed using SAP scripts and is been used for a quite long time. And now if there is a requirement to print some text in the form to print in a particular color, the only option available is to migrate to smartforms.

It would be of great help if this can be achieved with a little effort using the SAP scripts itself. Unfortunately there is no direct way provided by SAP as in smartforms to do the same, which gave me an opportunity to find out a way to do the same using SAP scripts.

This document explains how to print text in different colors in SAP scripts, what are all the different steps to be followed to achieve this.

 

Prerequisites:

  • Basic Knowledge in SAP scripts
  • Basic Knowledge in Smartforms

1.    Color Printing in Smartforms:Before going to the actual topic, we will see how to do this in smartforms. The color printing in smartforms is an easy & direct way provided by SAP to print the text in different colors.The option to choose the color is available in Smart Style as shown below.
Screen 1: Choose color in Smart StyleChoose_color.png

1.1. Steps to be followed:

    1. Create a format in the Smart Style by choosing a color in which the text to be printed.
    2. Use this format for the text in the Smartform to print that text in that particular color.
    3. Create different formats if the text to be printed in different colors and apply that particular format to the corresponding text to print the text in that color.

2.    Color Printing in SAP Scripts:

2.1. Work around done to achieve this functionality:

As we are aware, there is no such option provided by SAP in scripts to print the text in different colors. So some work around is done to achieve this functionality.

              

    1. Create a driver program to call the SAP Script (OPEN_FORM, WRITE_FORM and CLOSE_FORM) in order to get the OTF data.
    2. In the OTF data internal table, if the command is ‘ST’, it means the text. Before this line, insert a new line in the OTF internal table with the command ‘CT’ and for command parameters we need to give the font color (00800000 for yellow and FFFF0000 for green above).
    3. Call the FM ‘PRINT_OTF’.

 

2.2. Advantages:

 

    • The cost & effort that has to be incurred to migrate the SAP scripts to smartforms can be eliminated.
    • The coding effort will be minimal.

 

2.3. Testing Results:

The form can be printed in color as shown below.


Screen 2: Output of the Form

                        Result.png

 

 

Best Regards,

Sireesha Ch

SAP component hierarchy (search incident component F4)

$
0
0

The SAP support web site http://service.sap.com/incident allows to search for incidents (OSS message created by current SAP customer).

There is a selection screen field named component. By trying to select a component, a popup appears showing all possible values (SAP component hierarchy) :

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I try to find a way to download the all SAP component hierarchy. By searching on the internet "sap incident component list", i found a solution SAP OSS Note 36677 - Structure of components for customer messages.

 

==> An OSS note 36677 allows to download the SAP component hierarchy (file name is Component_structure.txt ; it has been zipped ; 24000 lines ; >1 MB). Here you can find screen shot of this file :

 

 

Then I tried to upload this SAP component hierarchy file into a SAP system. I created a report that is uploading the txt file and displaying it using SALV tree or grid. File is having 24000 entries. ==> the tree construction takes a long time.

Tree display looks like :

t

 

Grid display looks like :

 

 

 

 

 

 

The Report that is uploading the flat file and displaying data is attached.

Distribution list, Dynamic selection screen Variant and Schedule Background Job

$
0
0

Objective:  Using this document user can create the email distribution list, create dynamic selection variant and Schedule the background Job for which the output will be send to the email ID of distribution list.

 

·         Create Email Distribution list: Log in to SAP and on SAP easy access click on Business workplace.

 

 

1.JPG

 

Click on SAP Business Workplace.

 

2.JPG

 

Click on Distribution list.

 

3.JPG

Select the type of distribution channel list and then click on Create ICON.

4.JPG

 

Enter the Name, Title and then click ‘F4’  to select the folder.

 

5.JPG

 

Here select the existing folder or click on create folder.

 

6.JPG

Select the existing folder ‘TEST’.

 

7.JPG

 

Click on Distribution list content.

 

8.JPG

 

Add the email IDs in the list and also select the type To, CC, BCC and then save the list.

 

9.JPG

 

10.JPG

 

 

·         Create dynamic selection variant for Transaction ‘VA05N’ :

 

11.JPG

 

Here we will create the dynamic selection variant for document date it should be ‘current date – 3 days’ in from and To field.

 

12.JPG

Click on Save as Variant.

 

13.JPG

14.JPG

 

Give the variant name ,description and for the Document Date field Select ‘D’ in the Selection variable and then click on ‘F4’ help in Name of variable column.

 

15.JPG

Double click on  ‘Current date - xxx,current date + yyy’.

16.JPG

 

Enter ‘3’ in ‘a value for xxx’ and press enter and then ‘SAVE’.

 

17.JPG

Test the saved variant.

18.JPG

 

Select the variant ‘DVAR’.

 

19.JPG

 

We can see the dates as current date – 3 days.

 

·         Schedule the background Job : SM36

 

20.JPG

Enter the Job name and click on Step.

 

21.JPG

Enter the Program Name and Variant and then click on check and save button.

 

22.JPG

Now click back button.

 

23.JPG

Click on Spool list recipient to add the email distribution list.

 

24.JPG

Click on Search help and press ‘F4’.

 

25.JPG

Select the radio button ‘Distribution list’ and in Find enter the ID of distribution list which we have created the  press enter.

 

26.JPG

 

Click ‘Copy’.

 

27.JPG

Now click on ‘Start condition’.

 

28.JPG

 

Click ‘’Date/Time’.

 

29.JPG

Click on ‘Period values’.

 

30.JPG

 

Here select ‘Daily’ then check and save.

 

31.JPG

Enter the start date and time then check and save.

 

32.JPG

 

Now click on ‘SAVE’ button.

 

33.JPG

Now after the job is executed by system we can see the email.

 

34.JPG

 

"Excel Style" Database Analytics with 1 Line of ABAP Code

$
0
0

The new ALV with IDA (Integrated Data Access)  is able to process a high number of records withouth negative impact on performance. this works for HANA but also for non-hana Databases (except for the Fuzzy Search feature which only works with column based tables)

 

basically the IDA reads only the records from the database, which are shown on the screen, as soon as the user scrolls down or defines a filter column, the database is reloading this slice of records.

 

(remember: the old alv was like select * into itab so loading all records into application server memory and from there to the gui)

 

this way i can show a big table like bseg or vbap with millions of records in a second:

ALV.gif

and from there, the user can define filters, groups, sum/total columns, sorting, exel export etc

 

 

all this can be done with an abap report with only 1! line of code: (*method fullscreen is available from 7.40 SP5, IDA class is available from 7.40 SP0)

 

 

 

REPORT Z_ALV_HANA. cl_salv_gui_table_ida=>createiv_table_name = ‘VBAP' )->fullscreen( )->display( ).

 

 

 

 

i added some features to have a little more comfort: Dynamic Table Name, Title with number of records, possibility to Save ALV Layout Variants, Fuzzy Search

ALV_SELECTION_SCREEN.gif

 

REPORT Z_ALV_IDA.

 

DATA layout  TYPE lvc_s_layo.

DATA columns TYPE lvc_t_fcat.

DATA column  TYPE lvc_s_fcat.

data lv_title type SYTITLE.

data: go_alv_display type ref to cl_salv_gui_table_ida.

DATA: ls_persistence_key TYPE if_salv_gui_layout_persistence=>ys_persistence_key.

data: lv_count type i.

 

 

parameters: p_tab(30) default 'T000'.

parameters: p_sim type p length 2 decimals 1 default '0.8'.

parameters: p_search(50) lower case default 'Walldorf'.

 

data: lo_alv type ref to IF_SALV_GUI_TABLE_IDA.

 

 

start-of-selection.

 

 

lo_alv = cl_salv_gui_table_ida=>createiv_table_name = p_tab ).

 

* create title test

   select count( * ) from (p_tab) into lv_count.

   write lv_count to lv_title. condense lv_title.

   concatenate p_tab ': number of records in table:' lv_title  into lv_title separated by space.

   if p_search <> ' '.

   concatenate lv_title ',filtered by' p_search into lv_title separated by space.

   endif.

lo_alv->display_options( )->set_title( lv_title ).   "#EC NOTEXT

 

* enable save of alv variants:

     concatenate sy-repid '_' p_tab into ls_persistence_key-report_name.

*

     lo_alv->layout_persistence( )->set_persistence_options(

     EXPORTING

       is_persistence_key           = ls_persistence_key

       i_global_save_allowed        = 'X'

       i_user_specific_save_allowed = 'X' "l_user_specific_save_allowed'

   ).

 

* Search Feature

if p_sim <> 0.

     lo_alv->text_search( )->set_field_similarity( p_sim ).

endif.

if p_search <> ' '.

     lo_alv->text_search( )->set_search_term( |{ p_search }| ).

endif.

 

     call method lo_alv->fullscreen( )->display( ).


 

 

to test the performance you can use table DD03L with 9 Millions of Records in an empty ERP System

Favourite Objects Tool

$
0
0

If you are an ABAP developer, the chances of which should be high given that you are lurking around in the ABAP Development space, you must have come across situations in your projects where you had a string of development objects you worked on frequently. This string would have ran through objects of different types - classes, programs, function modules, tables, views etc. Often, this string would have been long enough to make you ruminate over the name of the object you wanted to work on next so that you could enter that name in the corresponding transaction (SE24, SE38, SE37 etc.) before engaging in a tete-a-tete with that object. What I would like to offer you is a simple tool that aspires to make it easier for you to keep a tab on your favourite objects and be able to navigate to them like a breeze.

 

The tool is built in ABAP and mainly comprises a report program, besides a few supporting objects. It makes use of a custom table where you can maintain your favourite objects. The good news is that you can maintain entries in the table from the tool's simple-to-use interface itself. Another good news is that it's not really mandatory for you to create this table and maintain data in it; if you don't, the tool automatically picks up, from TADIR, all objects authored by you and displays them as your favourites.

 

To give you a hint of what the tool's interface looks like, here is a screenshot:

 

As you can see, it neatly lists your favourite objects organized by the object type. You simply have to double-click on the object you want to navigate to and you will be taken there. Or, you can just right-click on the object and from the context menu, choose to open it in a new window so as not to lose the window hosting the tool.

 

In the application toolbar are buttons to add and delete favourite objects, and a button to open an object in a new window. You can either use these buttons or carry out the respective operation by choosing the relevant option from the context menu.

 

If you wish you can set the transaction for the tool as the start transaction so that as soon as you log on to your ABAP system, you are presented with your favourite objects.

 

If the above has sparked an interest in you, feel free to try out the tool and provide feedback. Below are instructions on how to deploy and use the tool.

 

Deploying the Tool

  1. Create the main report program
    1. Go to SE38 and create a new report program and copy the code from the attachment titled 'Favourite_Objects_Program.txt.'.
    2. Find the “SET PF-STATUS” statement in the report source code and double-click on the PF status “BUTTONS” to create the PF Status.
      1. Maintain application toolbar buttons ‘ADD’, ‘DELETE’ and ‘OP_NEW_WIN’ as shown in the screenshot below.

                        

                        

                    ii. Maintain PICK against function key F2 under ‘Recommended Function Key Settings’.

                        

                    iii. Activate the PF status.


          c. In the CONSTANTS section of the report source code, maintain values for the following constants:

               gc_fm_new_win – Add the name of your RFC function module for openings objects in new window as the value for this constant.

                gc_fav_obj_tab – Add the name of your favourite objects table as the value for this constant. If you do not wish to create the table (in which       case, the tool will automatically pick all objects authored by you from TADIR), you can leave this constant unchanged.

 

     2. Create the RFC Function Module for Openings Objects in New Window

    1. Go to SE37 and create an RFC function module
    2. Copy the code from the attachment titled 'Favourite_Objects_RFC.txt' to the function module and activate it.

 

     3. Create the Favourite Objects Table

          Note: This is an optional step. If you do not wish to create the favourite objects table, you need not do so. In such cases, the tool will automatically 

           pick objects you have authored from TADIR.

               a. Go to SE11 and create the favourite objects table having delivery class ‘C’

               b. Add the following fields to the table. Please use the same field names as in the screenshot else you will need to adjust the report source

   where these fields are being used.

                   

             c. Assign the search help (the one that would be created in step 4 below) for searching repository objects to field OBJ_NAME.

                   

               d. Maintain the technical settings of the table.

                   

                   

 

                e. Maintain the enhancement category of the table (preferably ‘Cannot be Enhanced’) and activate the table.


     4. Create the Search Help for Searching Development Objects

               a. Go to SE11 and create a search help according to the screenshot below.

                   

     

     5. Create a Transaction for Executing the Main Report Program

               a. Go to SE93 and create a transaction for your report program. You can use this transaction code to open the favourite objects tool and

                    additionally, you can set the transaction code as the start transaction (menu path: SAP Easy Access screen > Extras > Set Start Transaction).

 

 

Using the Tool

1. Launching the Tool

    1. If you have set the transaction for the tool as your start transaction, then it will automatically open up as soon as you log on to the system

            b. If you have not set it as your start transaction or you need to navigate to the tool from another open transaction, you can simply use the transaction

                code for the tool.


2. Adding Favourite Objects

           a. From the tool's application toolbar or the context menu, choose the option to add a favourite object. That should bring up the below pop-up.

              

 

          b. Enter the details of the object you want to add and click on Continue. The object will get added to your favourites and will instantly show up in the

              list.

 

3. Deleting Favourite Objects

     Simply click on the object you want to remove from your favourites and choose the option to delete either from the application toolbar or the context menu.

 

4. Navigating to a Favourite Object

          a. Method 1: Double-click on the object to open it in the same window.

          b. Method 2: Right-click on the object and choose 'Open in New Window' from the context menu to launch the object in a new window.

Customer Master Creation Using Class : CMD_EI_API

$
0
0

This Blog will clearly Explains that, Creation of Customer Master Record Using this Class : CMD_EI_API.

 

Generally for Customer Master Creation, we use BAPI's like BAPI_CUSTOMER_CREATEFROMDATA1 or BAPI_CUSTOMER_CREATEFROMDATA

But in all these Bapi's we need Customer Reference Number from one of the structure..

 

Mainly this Document is to create customer record, Without using  Customer Reference Number..

 

Please follow some below steps, here I have created in SE38 report program..

 

Program in SE38 :

 

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

*& REPORT  ZCUST_CR

*&

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

*&

*&

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

 

REPORT ZCUST_CR3.

 

 

*

TYPES : BEGINOF TY_XML ,

          RAW(2000) TYPEC,

         ENDOF TY_XML.

 

TYPES : BEGINOF TY_FILE,

           FILE TYPE STRING,

         ENDOF TY_FILE.

 

TYPES : BEGINOF TY_KUNNR,

           KUNNR TYPE KNA1-KUNNR,

         ENDOF TY_KUNNR.

 

DATA : IT_KUNNR TYPETABLEOF TY_KUNNR,

        WA_KUNNR TYPE TY_KUNNR.

 

DATA : WA_VAT_NUMBER TYPE CVIS_EI_VAT_NUMBERS,

        WA_VAT_T      TYPE CVIS_EI_VAT_T,

        WA_VAT        TYPE CVIS_EI_VAT,

        WA_PHONE      TYPE CVIS_EI_CVI_PHONE,

        WA_PH_T       TYPE CVIS_EI_PHONE_T,

        WA_PH_PH      TYPE CVIS_EI_PHONE_STR,

        WA_FAX        TYPE CVIS_EI_CVI_FAX,

        WA_FX_T       TYPE CVIS_EI_FAX_T,

        WA_FX_FX      TYPE CVIS_EI_FAX_STR,

        WA_SM_SMTP    TYPE CVIS_EI_SMTP_STR,

        WA_SMTP_T     TYPE CVIS_EI_SMTP_T,

        WA_SMTP       TYPE CVIS_EI_CVI_SMTP.

 

 

DATA : WA_HEADER          TYPE CMDS_EI_HEADER,

        WA_CENTRAL_DATA    TYPE CMDS_EI_VMD_CENTRAL_DATA,

        WA_CENTRAL_DATAX   TYPE CMDS_EI_VMD_CENTRAL_DATA_XFLAG,

        WA_ADDRESS         TYPE BAPIAD1VL,

        WA_ADDRESSX        TYPE BAPIAD1VLX,

        WA_TAX_IND_ST      TYPE CMDS_EI_TAX_IND,

        WA_TAX_IND         TYPE CMDS_EI_CMD_TAX_IND,

        WA_BANKDETAIL_ST   TYPE CVIS_EI_CVI_BANKDETAIL,

        WA_BANKDETAIL      TYPE CVIS_EI_BANKDETAIL,

        WA_COMPANY_CODE_ST TYPE CMDS_EI_COMPANY,

        WA_COMPANY_CODE    TYPE CMDS_EI_CMD_COMPANY,

 

        WA_CUSTOMER        TYPE CMDS_EI_EXTERN,

        WA_CUSTOMERS       TYPE CMDS_EI_MAIN,

        WA_CORRECT         TYPE CMDS_EI_MAIN,

        WA_DEFECTIVE       TYPE CMDS_EI_MAIN,

        WA_MES_CORRECT     TYPE CVIS_MESSAGE,

        WA_MES_ERROR       TYPE CVIS_MESSAGE.

 

DATA : EMAIL_SMTP TYPE CVIS_EI_SMTP_T.                """"EMAIL CONTACT ---

DATA : EMAIL      TYPE CVIS_EI_SMTP_STR,

        CONTACT    TYPE CVIS_EI_SMTP.

 

DATA : IT_PHONE TYPE CVIS_EI_PHONE_T,                """PHONE  AND FAX

        WAA_PHONE TYPE CVIS_EI_PHONE_STR,

        PH_CONTACT TYPE CVIS_EI_PHONE.

DATA : IT_FAX TYPE CVIS_EI_FAX_T,

        WAA_FAX TYPE CVIS_EI_FAX_STR,

        FAX_CONTACT TYPE CVIS_EI_FAX.

 

DATA : IT_CONT_PERSON TYPE CMDS_EI_CONTACTS_T,        """*WA_CUSTOMER - - DATA

        WA_CONT TYPE CMDS_EI_CONTACTS.

DATA : IT_PHONE_CONT TYPE CVIS_EI_PHONE_T.

 

DATA: WA_FUNCTIONS_ST    TYPE CMDS_EI_FUNCTIONS,      """"""SALES MANDATORY FIELDS

       WA_FUNCTIONS_T     TYPE CMDS_EI_FUNCTIONS_T,

       WA_FUNCTIONS       TYPE  CMDS_EI_FUNCTIONS_T,

       WA_SALES_DATA_ST   TYPE CMDS_EI_SALES,

       WA_SALES_DATA      TYPE CMDS_EI_CMD_SALES,

       IT_SALES TYPE CMDS_EI_SALES_T,

       WA_DATA TYPE CMDS_EI_SALES_DATA.

 

DATA : IT_MESSAGE TYPE BAPIRET2_T,                    """ERROR MESSAGES

        WA_MESS TYPE BAPIRET2.

 

DATA : CUST TYPE CMDS_EI_MAIN,                        """CUSTOMER RELATED

        KUNNR_CUST TYPE CMDS_EI_EXTERN_T,

        WA_KUN LIKELINEOF KUNNR_CUST,

*      WA_KUN LIKE LINE OF CMDS_EI_EXTERN,

        WA_CUST TYPE CMDS_EI_EXTERN,

        WA_CUSTON LIKELINEOF WA_CORRECT-CUSTOMERS,

        LV_KUNNR TYPE KUNNR.

 

DATA : LV_STRING TYPE STRING.                         """DISPLAY IN ALV

DATA : GT_OUTTAB TYPETABLEOF SFLIGHT.

DATA : GR_TABLE TYPEREFTO CL_SALV_TABLE.

 

CONSTANTS : C_UPDATE TYPECVALUE'M',

             C_INSERT TYPECVALUE'I'.

 

DATA : V_FILE  TYPE STRING,

        G_STR   TYPE STRING,

        XSTRING TYPE XSTRING.

 

DATA : IT_XML_INFO TYPETABLEOF SMUM_XMLTB WITHHEADERLINE,

        WA_XML_INFO LIKELINEOF IT_XML_INFO,

        RETURN  TYPESTANDARDTABLEOF BAPIRET2 .

 

DATA : IT_XML_TAB TYPETABLEOF TY_XML,

        WA_XML_TAB LIKELINEOF IT_XML_TAB.

 

 

DATA : LT_TABLE TYPESTANDARDTABLEOF EPSFILI,"FILE_INFO,

        LS_TABLE TYPE EPSFILI,"FILE_INFO,

        LT_FINAL TYPESTANDARDTABLEOF TY_FILE,

        L_COUNT TYPEI,

        L_DIRNAME TYPE   EPSF-EPSDIRNAM,

        L_FILE_LIST TYPETABLEOF EPSFILI."RSFILLST

 

        CLEAR LS_TABLE.

 

START-OF-SELECTION.

 

*PARAMETERS: P_TEST TYPE C AS CHECKBOX DEFAULT 'X'.

 

* A "CUSTOMER" IS MADE UP OF 4 MAIN SECTIONS

*    1. HEADER

*    2. CENTRAL_DATA

*    3. COMPANY_DATA

*    4  SALES_DATA

 

 

FREE: WA_CUSTOMER, WA_COMPANY_CODE_ST, WA_CUSTOMER.

 

   WA_ADDRESS-TITLE        = '0002.'.

   WA_ADDRESS-NAME       = 'SHANTHAN'.

   WA_ADDRESS-CITY         = 'BANGALORE'.

*  WA_ADDRESS-POSTL_COD1 = '505001'.    ""COMNT

*  WA_ADDRESS-STREET          = 'SBM COLONY'. ""COMNT

   WA_ADDRESS-COUNTRY        = 'IN'.

   WA_ADDRESS-LANGU             = 'EN'.

*  WA_ADDRESS-REGION          = '05'.         """COMNT

   WA_ADDRESS-SORT1              = 'REDDY'.

*  WA_ADDRESS-SORT2             = ''.

*  WA_ADDRESS-TAXJURCODE = 'FL0000000'.

* WA_ADDRESS-TIME_ZONE      = 'UTC-6'.

***

 

 

*WA_COMPANY_CODE_ST-DATA-AKONT = '23203110'.

 

 

   CALLFUNCTION'CONVERSION_EXIT_ALPHA_INPUT'

     EXPORTING

       INPUT  = '142000'

     IMPORTING

       OUTPUT = WA_COMPANY_CODE_ST-DATA-AKONT.

*  WA_COMPANY_CODE_ST-DATA-ZTERM = '0001'.

 

   WA_COMPANY_CODE_ST-DATA_KEY-BUKRS = '3000'.

 

   WA_CUSTOMER-CENTRAL_DATA-ADDRESS-POSTAL-DATA = WA_ADDRESS.

   WA_CUSTOMER-CENTRAL_DATA-ADDRESS-POSTAL-DATAX = WA_ADDRESSX.

 

   WA_COMPANY_CODE_ST-TASK           = C_INSERT.

 

   APPEND WA_COMPANY_CODE_ST TO WA_COMPANY_CODE-COMPANY.

 

**********************************************************************************************SALES ORG AND DIST & DIVISION MANDATORY FIELDS

 

WA_CUSTOMER-SALES_DATA-CURRENT_STATE = 'X'.

 

WA_SALES_DATA_ST-DATA_KEY-VKORG = '3000'.

WA_SALES_DATA_ST-DATA_KEY-VTWEG = '12'.

WA_SALES_DATA_ST-DATA_KEY-SPART = '00'.

 

*WA_DATA-ZTERM = '0001'.    """BELOW COMNT

WA_DATA-KALKS = '1'.

*WA_DATA-VERSG = '1'.

WA_DATA-VSBED = '02'.

*WA_DATA-INCO1 = 'AIR'.

*WA_DATA-INCO2 = 'INCOTERMS2'.

WA_DATA-WAERS = 'INR'.

*WA_DATA-AUFSD = '01'.

WA_SALES_DATA_ST-DATA = WA_DATA.

 

 

WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'AG'.

WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.

WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.

APPEND WA_FUNCTIONS_ST TO  WA_FUNCTIONS_T.

CLEAR: WA_FUNCTIONS_ST.

 

WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'RE'.

WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.

WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.

APPEND WA_FUNCTIONS_ST TO  WA_FUNCTIONS_T.

CLEAR: WA_FUNCTIONS_ST.

 

WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'RG'.

WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.

WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.

APPEND WA_FUNCTIONS_ST TO  WA_FUNCTIONS_T.

CLEAR: WA_FUNCTIONS_ST.

 

WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'WE'.

WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.

WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.

APPEND WA_FUNCTIONS_ST TO  WA_FUNCTIONS_T.

CLEAR: WA_FUNCTIONS_ST.

 

WA_SALES_DATA_ST-FUNCTIONS-CURRENT_STATE = 'X'.

WA_SALES_DATA_ST-FUNCTIONS-FUNCTIONS = WA_FUNCTIONS_T.

 

 

APPEND WA_SALES_DATA_ST TO IT_SALES.

 

WA_CUSTOMER-SALES_DATA-SALES = IT_SALES.

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

 

** ACCOUNT ACCOUNT GROUP DIRECTLY

   WA_CUSTOMER-CENTRAL_DATA-CENTRAL-DATA-KTOKD = 'ZARG'.

 

   WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR  = '   '.

   WA_CUSTOMER-HEADER-OBJECT_TASK            = C_INSERT.

   WA_CUSTOMER-COMPANY_DATA                  = WA_COMPANY_CODE.

 

   APPEND WA_CUSTOMER TO WA_CUSTOMERS-CUSTOMERS.

 

   CALLMETHOD CMD_EI_API=>MAINTAIN_BAPI

     EXPORTING

       IV_TEST_RUN         = ''

       IV_COLLECT_MESSAGES = 'X'

       IS_MASTER_DATA      = WA_CUSTOMERS

     IMPORTING

       ES_MASTER_DATA_CORRECT   = WA_CORRECT

       ES_MESSAGE_CORRECT       = WA_MES_CORRECT

       ES_MASTER_DATA_DEFECTIVE = WA_DEFECTIVE

       ES_MESSAGE_DEFECTIVE     = WA_MES_ERROR.

 

   IF WA_MES_ERROR-IS_ERROR ISINITIAL.

 

     CALLFUNCTION'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        WAIT          = 'X'

*     IMPORTING

*       RETURN        =

               .

"""""IF CUTOMER IS CREATED : DISPLAY CUSTOMER NUMBER  :: CUSTOMER RELATED

 

LOOPAT WA_CORRECT-CUSTOMERS INTO WA_CUSTON.

   WA_KUNNR-KUNNR = WA_CUSTON-HEADER-OBJECT_INSTANCE-KUNNR .

   APPEND WA_KUNNR TO IT_KUNNR.

   CLEAR : WA_KUNNR.

ENDLOOP.

*... CREATE INSTANCE

    CALLMETHOD CL_SALV_TABLE=>FACTORY

       IMPORTING

          R_SALV_TABLE = GR_TABLE

       CHANGING

          T_TABLE = IT_KUNNR.

*... DISPLAY TABLE

    GR_TABLE->DISPLAY( ).

 

ELSE""""SHOW ERROR MESSAGES

 

*... CREATE INSTANCE

    CALLMETHOD CL_SALV_TABLE=>FACTORY

       IMPORTING

          R_SALV_TABLE = GR_TABLE

       CHANGING

          T_TABLE = WA_MES_ERROR-MESSAGES.

*... DISPLAY TABLE

    GR_TABLE->DISPLAY( ).

 

   ENDIF.

 

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''AFTER SUCCESSFUL EXECUTION THE OUT PUT SCREEN IS LIKE BELOW

 

CUSTIMG.png

 

 

Hope this helps.


Thanks & Regards


Shanthan Reddy


Calling the method of class CL_RSD_DTA via FACTORY Method

$
0
0

Issue :

During the migration of SAP BW 7.0 to 7.4 project the call to the method of the class CL_RSD_DTA turns into error.

 

Analysis :

The method was called by creating instance of the class using  CREATE OBJECT statement and using that instance to call te method.

In the new 7.4 version the constructor of the class CL_RSD_DTA is no longer public and hence that goes into error.

 

Solution :

To resolve this issue we used the FACTORY method of the class to create its instance and used that instance to call the methods within that class.

 

Example :

 

Earlier Code :

CREATE OBJECT l_r_dta

    EXPORTING

      i_infoprov = l_s_rkb1d-infocube.

  CALL METHOD l_r_dta->dta_get_info

    IMPORTING

      e_s_dta = l_s_dta.


New Code :
CALL METHOD cl_rsd_dta=>factory

   EXPORTING

     i_infoprov = l_s_rkb1d-infocube

   RECEIVING

     r_r_dta    = l_r_dta

   EXCEPTIONS

     OTHERS     = 1.


  CALL METHOD l_r_dta->dta_get_info

    IMPORTING

      e_s_dta = l_s_dta.

 

 

pricing conditions in ME21N(abaper job)

$
0
0

Hi every one,

 

REQUIREMENT 1:

 

                  i have a requirement in ME21N(Po create)  pricing is determined as per the condition records maintained by our mm consultant but now he is asking for ZPCR he maintained value 09 in condition records but he asked to check the Material Master record( MBEW-VERPR by passingMBEW-BWKEY == EKPO-WERKS and MBEW- MATNR = MATNR ) and in that also if the price is mentioned let's say 100 then it should replace the value 9 and if not found then i need to display the value maitained in condition record.

 

REQUIREMENT 2:

 

                in ME21N  if one condition type  ex: ZPCR is exist then other condition type ZDTY  should not appear and if ZPCR is not exist then ZDTY can exist for the material which is mentioned in line item( if the condition type ZDTY maintained for it) .

 

 

GO TO : VOFM and click on REQUIREMENTS.

 

1.jpg

 

NOW SELECT THE RELAVANT ONE(IN OUR CASE PRICING)


2.jpg


GO TO LAST AND ENTER THE REQUIREMENT NUMBER EX: 986.


3.jpg

 

Then click on enter it will ask you the access key enter the access key then continue.by default two form routines are created.

 

Now place the cursor after the form name and click on insert from the application toolbar. Now write your custom code with in the insert(all above is just exit)

 

4.jpg

 

 

 

data:v1 type mbew-verpr.
**************************REQUIREMENT1*****************************************
* this select query is used to fetch the price if maintained in master record.
SELECT SINGLE VERPR FROM MBEW INTO V1 where matnr = komp-matnr and bwkey = komp-werks.
if v1 is not INITIAL.
read table tkomv[] INTO tkomv with key kschl = 'PB00'.
IF SY-SUBRC = 0.
tkomv
-kbetr = v1.
modify TABLE tkomv.
ENDIF.
endif.
*************************REQUIREMENT2******************************************
read table tkomv[] with key kschl = 'PB00' TRANSPORTING NO FIELDS.
if sy-subrc = 0.
delete tkomv[] where kschl = 'SKTO'.
endif.

 

 

NOW GO TO SPRO

SAP REFERENCE IMG ---------> MATERIAL MANAGEMENT ------------> PURCHASING ----------> CONDITIONS ------->DEFINE PRICE DETERMINATION PROCESS -------> DEFINE CALCULATION SCHEMA


5.jpg

 

 

Now find the relavant procedure which is active( and select it and click on control data


6.jpg

now enter the requirement that you created (ex: 986) as shown below.


7.jpg

 

Click on Save.

 

Testing the Requirement:


     

        A)     With Out Requirement: remove the requirement from the above screen and save.

                            

          Now go to ME21N

8.jpg

 

Select purchase orders

 

9.jpg

 

10.jpg

 

Click on execute

 

11.jpg

 

Click on adopt. Now observe the marked areas

 

12.jpg

 

B)     With Requirement: now add the requirement(ex: 986) in procedure and save it.now observe the difference.

 

       13.jpg

 

 

 

 







 

 

 



Assign Search help to Standard Structure

$
0
0

Requirement

Requirement is to have a customized Search help for a field present on standard Screen.

 

Analysis

  • First step is to find the Search help associated with that field. If standard search help is present, then solution will be to extend that Standard Search help as per the requirement.
  • If standard Search help is not associated with the field, then we can proceed with assigning a new search help with access key. But this is not a preferable option as changes with access key are not included in upgrades.
  • Second Approach - Using an Append structure. Steps are described below in a scenario.

 

SCENARIO

Quality Notification creation with reference to Sales Order: Tcode QM01

 

Current functionality:  F4 help for item (Field LS_KDPOS) displays item numbers associated with the sales number.

Requirement: F4 help for item (Field LS_KDPOS) should also display material number along with the item number.

 

Procedure

  1. Press F1 on the field for which search help has to be enhanced and get the structure name. Here the structure name is RQM01
  2. Standard Structure RQM01

Untitled.jpg

 

3. Click on Append Structure

Untitled.jpg

4. Provide the name and Description of the Append StructureUntitled.jpg

5. Click on button Show Appending Object

Untitled.jpg

6. The Following screen with all fields will be displayed

 

 

Untitled.jpg

7. Put your cursor on the field to which you want to attach the search help.

Here, we can see that search help associated with the field LS_KDPOS is check table VBUP.

Untitled.jpg

8. Now, click on button Search help and A pop up will come where you can specify the search help

Untitled.jpg

9. Assign the required search help in the Search help name. For my scenario, I found a standard search help which is available. Here we can use Z search help also. Activate the Append structure

 

RESULT

Now check the same in QM01

Press F4 on sales order Item to check our new search help assigned

Untitled.jpg

And, we got the new search help where we can see material and material description also along with Item Number

 

5.

Getting Google maps coordinates from inside of a Dialog program

$
0
0

Hi Abapers,

It was long time ago since I posted something on SCN and these days I'm trying to make, let's say, GIS inside SAP ERP..

So a wanted to be able to draw some polygon on map and then get his coordinates and save them inside SAPs database, but nowhere on the web I couldn't find the whole solution, just fragments. After a couple of days I finally made it and this is my most bare solution:

 

gps_scn.JPG

 

And the code of course:

 

*&---------------------------------------------------------------------*
*& Report  Z_VE_MAP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT z_ve_map.

* objects for browser
DATA: html_control TYPE REF TO cl_gui_html_viewer,
       html_container TYPE REF TO cl_gui_custom_container.

DATA: w_url TYPE char255.

TYPES : BEGIN OF y_html,
         dataset(255) TYPE c,
         END OF y_html.

DATA: e_data  TYPE y_html,
       ts_data TYPE STANDARD TABLE OF y_html.

DATA: myevent_tab TYPE cntl_simple_events,
       myevent TYPE cntl_simple_event.

DATA: ok_code LIKE sy-ucomm,
       save_ok LIKE sy-ucomm.

DATA: edframe(255),
       edaction(256),
       edgetdata(2048),
       edpostdataline(1024),
       postdata_tab TYPE cnht_post_data_tab,
       postdata_wa TYPE cnht_post_data_line,
       edquery_table TYPE cnht_query_table.

DATA: query_wa LIKE LINE OF edquery_table,
       coord_string TYPE string.

TYPESmytype TYPE char45.
DATA: lt_split TYPE TABLE OF mytype WITH HEADER LINE,
       ls_split TYPE mytype.

TYPES: BEGIN OF coord_type,
       flag TYPE c,
        rbr TYPE n LENGTH 3,
       coor TYPE char45,
        END OF coord_type.
DATA: coord_itab TYPE TABLE OF coord_type,
       coord_wa TYPE coord_type,
       counter TYPE n LENGTH 3 VALUE 0.

*****************************************************
*              CLASS cl_myevent_handler             *
*****************************************************
CLASS cl_myevent_handler DEFINITION.

   PUBLIC SECTION.
     METHODS: on_sapevent
                FOR EVENT sapevent OF cl_gui_html_viewer
                  IMPORTING action frame getdata postdata query_table.

ENDCLASS.                    "cl_myevent_handler DEFINITION
****************************************************
*    cl_myevent_handler implementation             *
****************************************************
CLASS cl_myevent_handler IMPLEMENTATION.

   METHOD on_sapevent.

     CLEAR: coord_string, lt_split, ls_split.

     LOOP AT postdata INTO postdata_wa.
       CONCATENATE coord_string postdata_wa INTO coord_string.
     ENDLOOP.

     SHIFT coord_string BY 4 PLACES.

     SPLIT coord_string AT ')' INTO TABLE lt_split.

     LOOP AT lt_split INTO ls_split.
       SHIFT ls_split LEFT DELETING LEADING ','.
       MODIFY lt_split FROM ls_split.
     ENDLOOP.
     CLEAR counter.
     LOOP AT lt_split INTO ls_split.
       SHIFT ls_split LEFT DELETING LEADING '('.
       MODIFY lt_split FROM ls_split.
       counter = counter + 1.
       coord_wa-rbr = counter.
       coord_wa-coor = ls_split.
       APPEND coord_wa TO coord_itab.
       CLEAR coord_wa.
     ENDLOOP.

   ENDMETHOD.                    "on_sapevent

ENDCLASS.                    "cl_myevent_handler IMPLEMENTATION

DATA: evt_receiver TYPE REF TO cl_myevent_handler.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

   IF html_container IS INITIAL.

     CREATE OBJECT html_container
       EXPORTING
         container_name              = 'CC_BROWSER'
       EXCEPTIONS
         cntl_error                  = 1
         cntl_system_error           = 2
         create_error                = 3
         lifetime_error              = 4
         lifetime_dynpro_dynpro_link = 5
         OTHERS                      = 6.
     CASE sy-subrc.
       WHEN 0.
*
       WHEN OTHERS.
         RAISE cntl_error.
     ENDCASE.
   ENDIF.

   IF html_control IS INITIAL.

     CREATE OBJECT html_control
       EXPORTING
         parent             = html_container
       EXCEPTIONS
         cntl_error         = 1
         cntl_install_error = 2
         dp_install_error   = 3
         dp_error           = 4
         OTHERS             = 5.

     IF sy-subrc <> 0.
       RAISE cntl_error.
     ENDIF.

*  register event
     myevent-eventid = html_control->m_id_sapevent.
     myevent-appl_event = 'x'.
     APPEND myevent TO myevent_tab.
     CALL METHOD html_control->set_registered_events
       EXPORTING
         events = myevent_tab.

     CREATE OBJECT evt_receiver.

     SET HANDLER evt_receiver->on_sapevent
                 FOR html_control.


     PERFORM build_html.

     CALL METHOD html_control->load_data
       EXPORTING
         type                 = 'text'
         subtype              = 'html'
       IMPORTING
         assigned_url         = w_url
       CHANGING
         data_table           = ts_data
       EXCEPTIONS
         dp_invalid_parameter = 1
         dp_error_general     = 2
         cntl_error           = 3
         OTHERS               = 4.


     CALL METHOD html_control->show_url
       EXPORTING
         url                    = w_url
       EXCEPTIONS
         cntl_error             = 1
         cnht_error_not_allowed = 2
         cnht_error_parameter   = 3
         dp_error_general       = 4
         OTHERS                 = 5.

   ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  BUILD_HTML
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_html .

   CLEAR e_data.
   FREE ts_data.

   DEFINE e_data.
     append &1 to ts_data.
   END-OF-DEFINITION.

   e_data:
   '<html><head>',
   '<meta name="viewport" content="initial-scale=1.0, user-scalable=no">',
   '<meta charset="utf-8">',
   '<style>html,body,#map-canvas{height:100%;margin:0px;padding:0px}</style>',
   '<script type="text/javascript" ',
   'src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=drawing"></script>',
   '<script> var map; var drawingManager; function initialize() {',
   'var mapOptions = { zoom: 10,',
   'center: new google.maps.LatLng(45.10842334, 20.15853882),',
   'mapTypeId: google.maps.MapTypeId.TERRAIN };',
   'map = new google.maps.Map(document.getElementById(''map-canvas''), mapOptions);',
   'drawingManager = new google.maps.drawing.DrawingManager({',
   'drawingMode: google.maps.drawing.OverlayType.POLYGON,',
   'drawingControl: false, polygonOptions: {',
   'fillColor: "#0080FF", fillOpacity: .6,',
   'strokeWeight: 1, strokeColor: "#150070",',
   'clickable: false, editable: true, zIndex: 1 } });',
   'drawingManager.setMap(map);',
   'google.maps.event.addListener(drawingManager, ''polygoncomplete'', function (polygon) {',
   'var coordinates = (polygon.getPath().getArray());',
   'var formInfo = document.forms[''info''];',
   'formInfo.gps.value = coordinates;',
   'document.getElementById("getcoord").submit(); }); }',
   'google.maps.event.addDomListener(window, ''load'', initialize);',
   '</script></head><body>',
   '<div id="map-canvas"></div>',
   '<form id="getcoord" method="POST" action=SAPEVENT:COORD name="info">',
   '<input type="hidden" name="gps" value=""></form>',
   '</body></html>'.


ENDFORM.                    " BUILD_HTML

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_COORD' ITSELF
CONTROLS: tc_coord TYPE TABLEVIEW USING SCREEN 0100.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_COORD'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE tc_coord_change_tc_attr OUTPUT.
   DESCRIBE TABLE coord_itab LINES tc_coord-lines.
ENDMODULE.                    "TC_COORD_CHANGE_TC_ATTR OUTPUT

*&SPWIZARD: INPUT MODUL FOR TC 'TC_COORD'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MARK TABLE
MODULE tc_coord_mark INPUT.
   DATA: g_tc_coord_wa2 LIKE LINE OF coord_itab.
   IF tc_coord-line_sel_mode = 1
   AND coord_wa-flag = 'X'.
     LOOP AT coord_itab INTO g_tc_coord_wa2
       WHERE flag = 'X'.
       g_tc_coord_wa2-flag = ''.
       MODIFY coord_itab
         FROM g_tc_coord_wa2
         TRANSPORTING flag.
     ENDLOOP.
   ENDIF.
   MODIFY coord_itab
     FROM coord_wa
     INDEX tc_coord-current_line
     TRANSPORTING flag.
ENDMODULE.                    "TC_COORD_MARK INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

   save_ok = ok_code.
   CLEAR ok_code.

   CASE save_ok.
     WHEN 'DEL'.
       CLEAR coord_itab.

   ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT



Feel free to ask a question and I will gladly answer if I know the answer

 

Happy coding!


Material Consumption Vs Purchasing History Month Wise

$
0
0

Dear Friends,

 

 

          Recently I had a requirement to create Material consumption , Purchase Condition price , Purchase a material from particular vendor based on the month wise report . Its is created using dynamic internal table .

 

Logic used:

 

1.Material,Vendor,Purchase price will be in first row.

 

2. Consumption price will be in 2nd row if purchase price is available else Consumption price will be in first row.

 

3. Logic I Used for raw material consumption and purchase details hot coded in the select query.

 

Dynamic Internal Table :

 

 

 

REPORT  zvendor_purchase_report MESSAGE-ID zvpr.

 

 

TYPE-POOLS: slis.

TABLES: mseg, mara.

 

TYPES: BEGIN OF ty_period,

   period(6) TYPE c,

   END OF ty_period,

 

BEGIN OF ty_out,

   month(2) TYPE c,

   year(4) TYPE c,

   mblnr TYPE mkpf-mblnr,

   budat TYPE mkpf-budat,

   knumv TYPE ekko-knumv,

   bwart TYPE mseg-bwart,

   matnr TYPE mseg-matnr,

   menge TYPE mseg-menge,

   tot_cons TYPE mseg-menge,

   maktx TYPE makt-maktx,

   lifnr TYPE mseg-lifnr,

   name1 TYPE lfa1-name1,

   kschl TYPE konv-kschl,

   price(15) TYPE c,

   kbetr TYPE konv-kbetr,

 

   END OF ty_out,

 

BEGIN OF ty_output,

   month(2) TYPE c,

   year(4) TYPE c,

   matnr TYPE mseg-matnr,

   maktx TYPE makt-maktx,

   lifnr TYPE ekko-lifnr,

   name1 TYPE lfa1-name1,

   price(15) TYPE c,

   kbetr TYPE konv-kbetr,

   menge TYPE mseg-menge,

   tot_consum TYPE mseg-menge,

   budat TYPE mkpf-budat,

   mblnr TYPE mkpf-mblnr,

   END OF ty_output,

 

BEGIN OF ty_price,

   knumv TYPE ekko-knumv,

   kschl TYPE konv-kschl,

   kbetr TYPE konv-kbetr,

   END OF ty_price,

 

   BEGIN OF ty_pur_qty,

   knumv TYPE ekko-knumv,

   kschl TYPE konv-kschl,

   kbetr TYPE konv-kbetr,

   END OF ty_pur_qty,

 

BEGIN OF ty_months,

   month(2) TYPE c,

   month_name(3) TYPE c,

   year(4) TYPE c,

END OF ty_months,

 

BEGIN OF ty_mseg,

   month(2) TYPE c,

   year(4) TYPE c,

   budat TYPE mkpf-budat,

   matnr TYPE mseg-matnr,

   menge TYPE mseg-menge,

   END OF ty_mseg,

 

BEGIN OF ty_matnr,

   matnr TYPE mseg-matnr,

   END OF ty_matnr.

 

DATA: wa_period TYPE ty_period,

       gt_fieldcat TYPE slis_t_fieldcat_alv,

       wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv,

       gt_fieldout TYPE slis_t_fieldcat_alv,

       wa_fieldout TYPE LINE OF slis_t_fieldcat_alv,

       gt_field TYPE lvc_t_fcat,

       wa_field TYPE lvc_s_fcat,

       gt_out TYPE TABLE OF ty_out,

       wa_out TYPE ty_out,

       gt_output TYPE TABLE OF ty_output,

       wa_output TYPE ty_output,

       gt_output1 TYPE TABLE OF ty_output,

       wa_output1 TYPE ty_output,

       gt_output5 TYPE TABLE OF ty_output,

       wa_output5 TYPE ty_output,

       wa_output2 TYPE ty_output,

       gt_months TYPE TABLE OF ty_months,

       wa_months TYPE ty_months,

       gt_price TYPE TABLE OF ty_price,

       wa_price TYPE ty_price,

       gt_mseg TYPE TABLE OF ty_mseg,

       wa_mseg TYPE ty_mseg,

       gt_261 TYPE TABLE OF ty_mseg,

       wa_261 TYPE ty_mseg,

       gt_matnr TYPE TABLE OF ty_matnr,

       wa_matnr TYPE ty_matnr.

 

DATA: gv_months TYPE vtbbewe-atage,

       gv_low_date TYPE sy-datum,

       gv_high_date TYPE sy-datum,

       gv_po_date_low TYPE sy-datum,

       gv_po_date_high TYPE sy-datum.

 

FIELD-SYMBOLS: <gfs_table> TYPE STANDARD TABLE,

                <gfs_table1> TYPE STANDARD TABLE.

 

PARAMETERS: p_werks TYPE mseg-werks OBLIGATORY.

PARAMETERS: p_low(6) TYPE c OBLIGATORY,

             p_high(6) TYPE c OBLIGATORY.

SELECT-OPTIONS: s_matnr FOR mseg-matnr.

 

AT SELECTION-SCREEN.

   IF NOT p_werks IS INITIAL.

*-- Validate Plant

     PERFORM plant.

*-- Check Plant Authorization

     AUTHORITY-CHECK OBJECT 'ZP_WERKS'

     ID 'P_WERKS' FIELD p_werks.

     IF sy-subrc NE 0.

       MESSAGE e001(zvpr) WITH p_werks.

     ENDIF.

   ENDIF.

 

START-OF-SELECTION.

   PERFORM get_months.

   PERFORM build_fieldcat.

   PERFORM get_data.

   PERFORM display_out.

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

*&      Form  GET_PERIOD

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM get_months .

   DATA: lv_ktx TYPE t247-ktx.

 

   CONCATENATE p_low '01' INTO gv_low_date.

   CONCATENATE p_high '01' INTO gv_high_date.

 

   CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'

     EXPORTING

       day_in            = gv_high_date

     IMPORTING

       last_day_of_month = gv_high_date

     EXCEPTIONS

       day_in_not_valid  = 1

       OTHERS            = 2.

 

   gv_po_date_low = gv_low_date.

   gv_po_date_high = gv_high_date.

   CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

     EXPORTING

       i_date_from          = gv_low_date

       i_date_to            = gv_high_date

    IMPORTING

*   E_DAYS               =

      e_months             = gv_months

*   E_YEARS              =

             .

 

   gv_low_date+4(2) = gv_low_date+4(2) - 1.

 

   DO gv_months TIMES.

 

     gv_low_date+4(2) = gv_low_date+4(2) + 1.

     IF gv_low_date+4(2) = 13.

       gv_low_date+0(4) = gv_low_date+0(4) + 1.

       gv_low_date+4(2) = 1.

     ENDIF.

 

     CLEAR: lv_ktx.

     SELECT SINGLE ktx INTO lv_ktx FROM t247

       WHERE spras = sy-langu

         AND mnr = gv_low_date+4(2).

 

     wa_months-month = gv_low_date+4(2).

     wa_months-month_name = lv_ktx.

     wa_months-year = gv_low_date+0(4).

     APPEND wa_months TO gt_months.

   ENDDO.

ENDFORM.                    "GET_months

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

*&      Form  BUILD_FIELDCAT

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM build_fieldcat .

*-> Build Field catalog

   CLEAR: wa_fieldcat.

   wa_fieldcat-fieldname = 'MATNR'.

   wa_fieldcat-seltext_l = 'Material Code'.

   wa_fieldcat-tabname = 'GT_OUTPUT'.

   wa_fieldcat-outputlen = 25.

   wa_fieldcat-key = 'X'.

   APPEND wa_fieldcat TO gt_fieldcat.

 

   CLEAR: wa_fieldcat.

   wa_fieldcat-fieldname = 'MAKTX'.

   wa_fieldcat-seltext_l = 'Material Description'.

   wa_fieldcat-tabname = 'GT_OUTPUT'.

   wa_fieldcat-outputlen = 30.

   wa_fieldcat-key = 'X'.

   APPEND wa_fieldcat TO gt_fieldcat.

 

   CLEAR: wa_fieldcat.

   wa_fieldcat-fieldname = 'LIFNR'.

   wa_fieldcat-seltext_l = 'Vendor Number'.

   wa_fieldcat-tabname = 'GT_OUTPUT'.

   wa_fieldcat-outputlen = 15.

   wa_fieldcat-key = 'X'.

   APPEND wa_fieldcat TO gt_fieldcat.

 

   CLEAR: wa_fieldcat.

   wa_fieldcat-fieldname = 'NAME1'.

   wa_fieldcat-seltext_l = 'Name of the Vendor'.

   wa_fieldcat-tabname = 'GT_OUTPUT'.

   wa_fieldcat-outputlen = 50.

   APPEND wa_fieldcat TO gt_fieldcat.

 

   CLEAR: wa_months.

   LOOP AT gt_months INTO wa_months.

     CLEAR: wa_fieldcat.

     CONCATENATE wa_months-month_name wa_months-year '_' 'PRICE' INTO wa_fieldcat-fieldname.

     CONCATENATE wa_months-month_name wa_months-year '-' 'Price' INTO wa_fieldcat-seltext_l.

     wa_fieldcat-tabname = 'GT_OUTPUT'.

     wa_fieldcat-ref_tabname = 'KONV'.

     wa_fieldcat-ref_fieldname = 'KBETR'.

     wa_fieldcat-outputlen = 25.

     APPEND wa_fieldcat TO gt_fieldcat.

 

     CLEAR: wa_fieldcat.

     CONCATENATE wa_months-month_name wa_months-year '_' 'PUR_QTY' INTO wa_fieldcat-fieldname.

     CONCATENATE wa_months-month_name wa_months-year '-' 'Purchase Quantity' INTO wa_fieldcat-seltext_l.

     wa_fieldcat-tabname = 'GT_OUTPUT'.

     wa_fieldcat-ref_tabname = 'MSEG'.

     wa_fieldcat-ref_fieldname = 'menge'.

     wa_fieldcat-outputlen = 25.

     APPEND wa_fieldcat TO gt_fieldcat.

 

     CLEAR: wa_fieldcat.

     CONCATENATE wa_months-month_name wa_months-year '_' 'TOT_CONSUM' INTO wa_fieldcat-fieldname.

     CONCATENATE wa_months-month_name wa_months-year '-' 'Total Consumption' INTO wa_fieldcat-seltext_l.

     wa_fieldcat-tabname = 'GT_OUTPUT'.

     wa_fieldcat-ref_tabname = 'MSEG'.

     wa_fieldcat-ref_fieldname = 'menge'.

*    wa_fieldcat-do_sum = 'X'.

     wa_fieldcat-outputlen = 25.

     APPEND wa_fieldcat TO gt_fieldcat.

   ENDLOOP.

 

ENDFORM.                    " BUILD_FIELDCAT

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

*&      Form  DISPLAY_OUT

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM display_out .

   DATA: lt_sort TYPE slis_t_sortinfo_alv,

         lwa_sort TYPE LINE OF slis_t_sortinfo_alv.

 

   CLEAR: lwa_sort.

   lwa_sort-fieldname = 'MATNR'.

   lwa_sort-up = 'X'.

   APPEND lwa_sort TO lt_sort.

 

   CLEAR: lwa_sort.

   lwa_sort-fieldname = 'MAKTX'.

   lwa_sort-down = 'X'.

   APPEND lwa_sort TO lt_sort.

 

   CLEAR: lwa_sort.

   lwa_sort-fieldname = 'LIFNR'.

   lwa_sort-up = 'X'.

   APPEND lwa_sort TO lt_sort.

 

   CLEAR: lwa_sort.

   lwa_sort-fieldname = 'NAME1'.

   lwa_sort-up = 'X'.

   APPEND lwa_sort TO lt_sort.

 

   IF <gfs_table> IS INITIAL.

     MESSAGE s000(zvpr) WITH 'No data to display!'.

   ELSEIF <gfs_table> IS NOT INITIAL.

 

     CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

       EXPORTING

         i_callback_program = sy-repid

         i_save             = 'X'

         it_sort            = lt_sort

         it_fieldcat        = gt_fieldcat

       TABLES

         t_outtab           = <gfs_table>.

   ENDIF.

ENDFORM.                    " DISPLAY_OUT

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

*&      Form  plant

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

*       text

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

FORM plant .

 

   DATA l_werks TYPE werks_d.

 

   IF l_werks IS INITIAL.

     CLEAR l_werks.

   ENDIF.

 

   SELECT SINGLE werks

            FROM t001w

            INTO l_werks

           WHERE werks EQ p_werks.

 

   IF sy-subrc NE 0.

*Error Message (Enter a valid plant)

     MESSAGE e002(zvpr).

   ENDIF.

 

ENDFORM.                    " PLANT

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

*&      Form  GET_DATA

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM get_data .

   DATA: lt_dyntab TYPE REF TO data,

         lwa_dyntab TYPE REF TO data,

         lt_dyntab1 TYPE REF TO data,

         lwa_dyntab1 TYPE REF TO data,

         lv_ktx TYPE t247-ktx,

         lv_kbetr TYPE konv-kbetr,

         lv_menge TYPE mseg-menge,

         lv_tot_cons TYPE mseg-menge,

         lv_lifnr(15) TYPE c VALUE 'LIFNR',

         lv_matnr(18) TYPE c VALUE 'MATNR',

         lv_pur_qty(20) TYPE c,

         lv_price(20) TYPE c,

         lv_tot_consum(20) TYPE c,

         lv_year(4) TYPE c,

         lv_tabix TYPE sy-tabix,

         lv_index TYPE sy-index,

         lv_lines TYPE i,

         lv_delete TYPE c,

         lv_no_star TYPE c.

 

   FIELD-SYMBOLS : <lfs_wa> TYPE ANY,

                  <lfs_wa1> TYPE ANY,

                  <lfs_fld> TYPE ANY,

                  <lfs_matnr> TYPE ANY,

                  <lfs_maktx> TYPE ANY,

                  <lfs_lifnr> TYPE ANY,

                  <lfs_name1> TYPE ANY,

                  <lfs_tot> TYPE ANY.

 

   CLEAR: gt_out.

   SELECT mkpf~mblnr mkpf~budat mseg~bwart mseg~matnr mseg~lifnr mseg~menge mseg~ebeln

                   mkpf~budat

                   ekko~knumv

                   makt~maktx

                   lfa1~name1

     INTO CORRESPONDING FIELDS OF TABLE gt_out FROM mseg AS mseg

     INNER JOIN mkpf AS mkpf ON mkpf~mblnr = mseg~mblnr AND mkpf~mjahr = mseg~mjahr

     INNER JOIN ekko AS ekko ON ekko~ebeln = mseg~ebeln

     INNER JOIN makt AS makt ON makt~matnr = mseg~matnr

     INNER JOIN lfa1 AS lfa1 ON lfa1~lifnr = mseg~lifnr AND lfa1~spras = 'EN'

     INNER JOIN mara AS mara ON mara~matnr = mseg~matnr

     WHERE mkpf~budat GE gv_po_date_low AND mkpf~budat LE gv_po_date_high

       AND mara~mtart = 'ROH'

       AND mseg~matnr IN s_matnr

       AND mseg~werks = p_werks

       AND mseg~bwart = '101'.

 

   IF gt_out IS NOT INITIAL.

 

     SELECT knumv

       kschl

       kbetr

       INTO CORRESPONDING FIELDS OF TABLE gt_price

       FROM konv FOR ALL ENTRIES IN gt_out

       WHERE knumv = gt_out-knumv

         AND kschl = 'P000'.

   ENDIF.

   CLEAR: gt_mseg.

   SELECT mseg~matnr mseg~lifnr mseg~menge mkpf~budat

     INTO CORRESPONDING FIELDS OF TABLE gt_mseg

     FROM mseg AS mseg

     INNER JOIN mkpf AS mkpf ON mkpf~mblnr = mseg~mblnr AND mkpf~mjahr = mseg~mjahr

     INNER JOIN mara AS mara ON mara~matnr = mseg~matnr AND mara~mtart = 'ROH'

     WHERE  mkpf~budat GE gv_po_date_low AND mkpf~budat LE gv_po_date_high

       AND mseg~bwart = '261'

       AND mseg~matnr IN s_matnr

       AND mseg~werks = p_werks.

 

   CLEAR: wa_mseg.

   LOOP AT gt_mseg INTO wa_mseg.

     wa_mseg-month = wa_mseg-budat+4(2).

     wa_mseg-year = wa_mseg-budat+0(4).

     MODIFY gt_mseg FROM wa_mseg TRANSPORTING month year.

   ENDLOOP.

 

   SORT gt_mseg BY matnr year month .

 

   CLEAR: wa_mseg, lv_menge.

 

     LOOP AT gt_mseg INTO wa_mseg.

       lv_menge = lv_menge + wa_mseg-menge.

       CLEAR: lv_year, lv_matnr.

       lv_year = wa_mseg-year.

       lv_matnr = wa_mseg-matnr.

       AT END OF month.

         CLEAR: wa_261.

         MOVE-CORRESPONDING wa_mseg TO wa_261.

         wa_261-year = lv_year.

         wa_261-menge = lv_menge.

         wa_261-matnr = lv_matnr.

         APPEND wa_261 TO gt_261.

         CLEAR: wa_mseg, lv_menge, lv_year, lv_matnr.

       ENDAT.

     ENDLOOP.

 

     SORT gt_out BY lifnr matnr.

     CLEAR: wa_out, lv_kbetr.

     LOOP AT gt_out INTO wa_out.

       wa_out-month = wa_out-budat+4(2).

       wa_out-year = wa_out-budat+0(4).

       READ TABLE gt_price INTO wa_price WITH KEY knumv = wa_out-knumv.

       IF sy-subrc IS INITIAL.

         wa_out-kbetr = wa_price-kbetr.

       ENDIF.

 

       CLEAR: lv_ktx.

       SELECT SINGLE ktx INTO lv_ktx FROM t247

         WHERE spras = sy-langu

           AND mnr = wa_out-budat+4(2).

 

       wa_out-price = lv_ktx.

       CONCATENATE lv_ktx wa_out-year '_' 'PRICE' INTO wa_out-price.

 

       CLEAR: wa_output.

       MOVE-CORRESPONDING wa_out TO wa_output.

 

 

 

       APPEND wa_output TO gt_output.

       CLEAR wa_output.

 

     ENDLOOP.

 

 

     LOOP AT gt_261 INTO wa_261.

       wa_output-year = wa_261-year.

       wa_output-month = wa_261-month.

       wa_output-matnr = wa_261-matnr.

       wa_output-tot_consum = wa_261-menge.

       APPEND wa_output TO gt_output.

       CLEAR wa_output.

     ENDLOOP.

 

     CLEAR: wa_fieldcat.

     LOOP AT gt_fieldcat INTO wa_fieldcat.

       CLEAR: wa_field.

       MOVE-CORRESPONDING wa_fieldcat TO wa_field.

       APPEND wa_field TO gt_field.

     ENDLOOP.

 

     CALL METHOD cl_alv_table_create=>create_dynamic_table

       EXPORTING

         it_fieldcatalog = gt_field

       IMPORTING

         ep_table        = lt_dyntab.

 

     ASSIGN lt_dyntab->* TO <gfs_table>.

     CREATE DATA lwa_dyntab LIKE LINE OF <gfs_table>.

     ASSIGN lwa_dyntab->* TO <lfs_wa>.

 

     SORT gt_output BY mblnr budat ASCENDING.

*    .

 

     APPEND LINES OF gt_output TO gt_output1.

 

     CLEAR: wa_output.

     LOOP AT gt_output INTO wa_output.

       CLEAR: wa_fieldcat.

 

       ASSIGN COMPONENT 'MATNR' OF STRUCTURE <lfs_wa> TO <lfs_fld>.

       IF sy-subrc IS INITIAL.

         <lfs_fld> = wa_output-matnr.

       ENDIF.

 

       ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <lfs_wa> TO <lfs_fld>.

       IF sy-subrc IS INITIAL.

         <lfs_fld> = wa_output-maktx.

       ENDIF.

 

       ASSIGN COMPONENT 'LIFNR' OF STRUCTURE <lfs_wa> TO <lfs_fld>.

       IF sy-subrc IS INITIAL.

         <lfs_fld> = wa_output-lifnr.

       ENDIF.

 

       ASSIGN COMPONENT 'NAME1' OF STRUCTURE <lfs_wa> TO <lfs_fld>.

       IF sy-subrc IS INITIAL.

         <lfs_fld> = wa_output-name1.

       ENDIF.

 

       CLEAR: wa_output1.

       LOOP AT gt_field INTO wa_field WHERE fieldname NE 'MATNR' AND fieldname NE 'MAKTX' AND fieldname NE 'LIFNR' AND fieldname NE 'NAME1'.

         ASSIGN COMPONENT wa_field-fieldname OF STRUCTURE <lfs_wa> TO <lfs_fld>.

         IF sy-subrc IS INITIAL.

           READ TABLE gt_output1 INTO wa_output1 WITH KEY matnr = wa_output-matnr lifnr = wa_output-lifnr price = wa_field-fieldname.

           IF sy-subrc IS INITIAL.

             DELETE gt_output1 INDEX sy-tabix.

             <lfs_fld> = wa_output1-kbetr.

 

             lv_pur_qty = wa_output1-price.

             REPLACE FIRST OCCURRENCE OF 'PRICE' IN lv_pur_qty WITH 'PUR_QTY'.

             ASSIGN COMPONENT lv_pur_qty OF STRUCTURE <lfs_wa> TO <lfs_fld>.

             IF sy-subrc IS INITIAL.

               <lfs_fld> = wa_output1-menge.

             ENDIF.

           ENDIF.

         ELSEIF sy-subrc IS NOT INITIAL.

           EXIT.

         ENDIF.

       ENDLOOP.

       APPEND <lfs_wa> TO <gfs_table>.

       CLEAR: <lfs_wa>.

     ENDLOOP.

 

*Delete entries with empty dynamic field value

     LOOP AT <gfs_table> ASSIGNING <lfs_wa>.

       lv_tabix = sy-tabix.

       lv_index = 5.

       DO .

         lv_delete = 'X'.

         ASSIGN COMPONENT lv_index OF STRUCTURE <lfs_wa> TO <lfs_fld>.

         IF sy-subrc IS INITIAL.

           IF <lfs_fld> IS NOT INITIAL.

             lv_delete = ''.

             EXIT.

           ENDIF.

         ELSEIF sy-subrc IS NOT INITIAL.

           EXIT.

         ENDIF.

         lv_index = lv_index + 1.

       ENDDO.

       IF lv_delete = 'X'.

         DELETE <gfs_table> INDEX lv_tabix.

       ENDIF.

     ENDLOOP.

 

     gt_output1[] = gt_output[].

 

     DELETE gt_output1 WHERE tot_consum = '0.000'.

     SORT gt_output1 BY matnr price tot_consum.

     DELETE ADJACENT DUPLICATES FROM gt_output1 COMPARING matnr price tot_consum.

 

     CALL METHOD cl_alv_table_create=>create_dynamic_table

       EXPORTING

         it_fieldcatalog = gt_field

       IMPORTING

         ep_table        = lt_dyntab1.

 

     ASSIGN lt_dyntab1->* TO <gfs_table1>.

     CREATE DATA lwa_dyntab1 LIKE LINE OF <gfs_table1>.

     ASSIGN lwa_dyntab1->* TO <lfs_wa1>.

 

     CLEAR: wa_output1, wa_matnr.

     LOOP AT gt_output1 INTO wa_output1.

       wa_matnr-matnr = wa_output1-matnr.

       APPEND wa_matnr TO gt_matnr.

     ENDLOOP.

 

     SORT gt_matnr BY matnr.

     DELETE ADJACENT DUPLICATES FROM gt_matnr COMPARING matnr.

 

     CLEAR: wa_matnr.

     LOOP AT gt_matnr INTO wa_matnr.

 

       LOOP AT gt_output1 INTO wa_output1 WHERE matnr = wa_matnr-matnr.

         ASSIGN COMPONENT 'MATNR' OF STRUCTURE <lfs_wa1> TO <lfs_matnr>.

         lv_pur_qty = wa_output1-price.

 

 

         CLEAR: lv_ktx.

         SELECT SINGLE ktx INTO lv_ktx FROM t247

           WHERE spras = sy-langu

             AND mnr = wa_output1-month.

 

         CONCATENATE lv_ktx wa_output1-year '_' 'TOT_CONSUM' INTO lv_pur_qty.

 

 

         ASSIGN COMPONENT lv_pur_qty OF STRUCTURE <lfs_wa1> TO <lfs_tot>.

         IF sy-subrc IS INITIAL.

           READ TABLE gt_output1 INTO wa_output2 WITH KEY matnr = wa_output1-matnr.

           IF sy-subrc IS INITIAL.

             ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <lfs_wa1> TO <lfs_maktx>.

             ASSIGN COMPONENT 'LIFNR' OF STRUCTURE <lfs_wa1> TO <lfs_lifnr>.

             ASSIGN COMPONENT 'NAME1' OF STRUCTURE <lfs_wa1> TO <lfs_name1>.

 

             IF lv_no_star = ''.

               <lfs_maktx> = '*'.

               <lfs_lifnr> = '*'.

             ELSEIF lv_no_star = 'X'.

               <lfs_maktx> = wa_output1-maktx.

               <lfs_lifnr> = wa_output1-lifnr.

             ENDIF.

             <lfs_matnr> = wa_output1-matnr.

 

             <lfs_tot> = wa_output1-tot_consum.

           ENDIF.

         ELSEIF sy-subrc IS NOT INITIAL.

           EXIT.

         ENDIF.

 

       ENDLOOP.

 

       APPEND <lfs_wa1> TO <gfs_table1>.

       CLEAR: <lfs_wa1>.

     ENDLOOP.

 

     APPEND LINES OF <gfs_table1> TO  <gfs_table>.

 

   ENDFORM.                    " GET_DATA


Input Screen :

VENOR.jpg



Output Screen :



output.jpg


Report for doxygen documentation for ABAP sources

$
0
0

The attached report generates doxygen / plant uml documentation from an abap developoment package.

There are the following prerequisites:

1.) you need doxygen and plantUml installed in (c:\tools\plantuml, i.e. plantuml.jar needs to be there)

2.) you need a directory c:\src (this directory will be used as a workdirectory, files in this directory will be created, overwritten and deleted)

4.) you need the file dp.bat in c:\tools, (you find the file in the attached as a txt file, please rename to dp.bat)

5.) you need the report zmu_dump_class activated in your BW system. (BW 7.40).

If you run the report, you need to provide the name of a development package and then the documentation is generated.

You find the generated documentation in c:\src\html after a successfull run of zmu_dump_class.

 

Documentation is generated by extracting class/interface/method/ddic documentation, storing them as c header files in c:\src

and then running doxygen over these files. You can include plantUML in the abap documenation and get uml diagrams included. Class diagrams

will be included in any case.

 

Please note that there is no guaranteed support its just a tool I wrote for my convenience and a tool I think it's worth sharing.

SAP ABAP HR Display Additional Fields in Payslip India

$
0
0

SAP ABAP HR India.

This document contains the step via step procedure to create and Display Additional Fields in Pay slip India.

 

Display HR Additional Fields in Pay slip

Create a Structure which will be used later to display data.

Here I create the structure ZHR_ZFILD, with all the required fields which I want to display in payslip.

Stru.png

Define a Work area of type ZHR_ZFILD inside include RPCEDDZ9. We will fill this work area later and it will hold actual data for display.

Data_Decl.jpg

 

Main Program: HINCEDT0

Include : RPCEDSZ9

Create a Enhancement ZEI_RPCEDSZ9_EMPLOYEEDATA in the include RPCEDSZ9, Inside FORMREFRESH_PERNR_MOD.

Create a Include ZHR_RPCEDSZ9_EMPDATA In the enhancement where we will read the data an fill our work area ZFILD.

Enhance.png

 

Inside this Include write a code to fill the values into those fields.

Code.png

 

Now add these 2 fields using transaction: - PE51_CHECKTAB

PE51_CHECKTAB.png

 

Now in PE51.

Add the fields to be displayed on Pay slip in “Text Modules”

After that go to window option, position your fields on the form and link it to the table and fields we create earlier.

PE51_Disp.png

 

Now just do the alignment of your fields on that form and link it to the table and field. Data will come on the payslip.

 

Thanks

Satyam

 

Declaration:- I have created this document based on my experience and knowledge and It does not violets any copyrights.


Automate Header Pricing Conditions on Sales Orders

$
0
0

Business Scenario: Automate freight header pricing condition type on sales order at the header level.  Currently SAP doesn't have the capability to automate header condition types.  What we mean by automate is, for example, item condition types, you can set those up with a condition record and when certain criteria is met the record is automatically inserted into the sales order.  Transaction VK11/VK12/VK13 allows you to enter in the condition record type and then create/change/display records for different condition types.

 

Solution: Put some custom code within the sales order user exit MV45AFZZ.  There are several places in which custom code can be placed in order to update the sales order header condition type.  One place the code can be put is the FORM userexit_save_document_prepare (which is the form that gets executed one time right before the sales document gets saved.  Another place and probably the best place to put it is in the FORM userexit_pricing_prepare_tkomk.  In our solution we have placed the code in the FORM userexit_pricing_prepare_tkomk.  Depending on the way the environment is setup you will either have to create an enhancement or you can just update the code directly.  In our example we are updating the code directly.  If you need to do an enhancement or would like assistance using other FORMS feel free to ask for pointers.

 

1. Go to SE38 and enter in MV45AFZZ and click on change.  (If it asks you for an object key that means you need to create an enhancement).

2. Go down to the FORM userexit_pricing_prepare_tkomk.

3. In our instance we only wanted to update the header freight condition type on the creation of the sales order.  In order to do this you need to start your custom code with an "if" statement that checks to make sure that t180-trtyp = 'H'.  If it does, that means that it's in creation mode.  The snippet of code I'm pasting is in relation to pulling information from a custom table to determine what the condition record should be and update the incoterms and payment terms along with the condition record.

4. Also note in the code that there is a global variable that is set, gv_update_pricing.  We had to do this in order for the new pricing to update automatically since the terms were being updated.  This code needs to be placed in the FORM userexit_new_pricing_vbkd of user exit MV45AFZB.  I've put the code, in order to update the pricing automatically, down below also.  And again this is only done when creating the sales order.

 

 

codesnippet.jpg

Debugging loop

$
0
0

Did you ever had to step into loop looking for 46-th row or looking for occurrence of some value?

Instead of painful record by record stepping trough loop, why not use breakpoints/watchpoints?

While debugging one can do this:

 

 

1. Open up Breakpoints/Watchpoints tab

Debugger1.PNG

 

 

2. Select breakpoint:

Debugger2.png

 

 

3. Set break point condition:

Debugger3.png

 

 

4. Continue debugging (F8):

Debugger4.png

 

 

5. This is it: debugger stops at 46-th record of the loop.

Debugger5.png

 

 

6. In case one need to stop at some specific value - at the step 3 specific condition is entered:

Debugger6.png

 

Small but useful debugging trick, I hope it will be helpful!

 

Regards,

Mario

Guides and Tutorials for the Developer Edition of AS ABAP incl. BW on SAP HANA

$
0
0

The Developer Edition of AS ABAP incl. BW on SAP HANA comes with pre-configured users and pre-installed sample applications. Thus, you can immediately start developing or trying out new capabilities and code samples. Please find below a list of guides and tutorials which are already implemented in or are applicable for this developer edition.

 

Remark: Some of these guides and tutorials can only be used on SAP HANA, others also apply to AnyDB systems, e.g. the AS ABAP on MaxDB trial. Thus, all guides and tutorials are labeled accordingly*.

 

SAP HANA Developer Guide [SAP HANA*]

This guide explains how to build applications using SAP HANA, including how to model data, how to write procedures, and how to build application logic in SAP HANA Extended Application Services (SAP HANA XS).

 

SHINE: SAP HANA Interactive Education [SAP HANA*]

SAP HANA Interactive Education, or SHINE, is a demo application that makes it easy to learn how to build

native SAP HANA applications. The demo application comes with sample data and design-time developer objects for the application's database tables, data views, stored procedures, OData, and user interface.

 

ABAP for SAP HANA Reference Scenario [SAP HANA*]

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.

 

Developing a Java extension on SAP HANA Cloud Platform using JCo/RFC [AnyDB*]

In this tutorial you will develop a Java extension on SAP HANA Cloud Platform using a JCo/RFC connection to your ABAP system in the cloud or on-premise. The scenario used in this tutorial is based on the well-known SFLIGHT model.

 

Business Warehouse Scenarios [SAP HANA*]

The developer edition includes SAP Business Warehouse 7.4 which provides pre-activated sample scenarios for selected OLAP functions and integrated planning. Moreover, it contains predefined objects, such as InfoProviders, Queries and Workbooks. For more information please refer to this page or use transaction RSFC directly in the system.

 

How to implement an OData service with SAP NetWeaver Gateway [AnyDB*]

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 [AnyDB*]

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 pleasedownload the how-to guide from SCN.


Employee Photo - Bitmap Automation (for Dynamic Employee Photos in Smartforms)

$
0
0

EMPLOYEE PHOTO - BITMAP AUTOMATION

( TO BE DISPLAYED ON SMARTFORMS )

 

Recently we needed the functionality to print Employee Photos on smartforms. As smartforms only show BMP files uploaded via SE78 and employee photos are mostly JPG files with different stories we had to make some sort of automation that gets the employee photo, converts it to bitmap file and upload this BMP file to SE78 via background processing.

 

1. Displaying Pictures Dynamically in Smartforms

 

First we create a dummy smartform and an input parameter for SE78 file name (IPERNR in our case).

 

1.jpg

 

Then we put a graphic component in our smartform  parameters as below.

 

2.jpg

 

Here; &IPERNR& variable should have the name of an SE78 GRAPHICS file with ID = BMAP and type = BCOL (for Colored Images).

 

3.jpg

 

Below screenshots are smartform test screen and SE78 display screen, IPERNR parameter has the same name as image name in SE78.

 

21.jpg

5.jpg

 

We can see and print the image succesfully.

 

6.jpg

 

2. Converting External Image Formats (JPG/GIF/TIFF/PNG) to Bitmap

 

SAP has a class CL_IGS_IMAGE_CONVERTOR for these purposes.

 

7.jpg

 

This class has below public methods that all together used to set and convert image files with extensions JPG, GIF, TIFF and PNG.

 

8.jpg

 

There is a prerequisite to use this class properly and that is IGS (Internet Graphics Server) must be up and running. If IGS is not installed and configured, you should receive RFC Destination error. IGS is explained below.

 

 

 

3. IGS (Internet Graphics Server)


"Execute" method of class CL_IGS_IMAGE_CONVERTER uses below RFC destination as default to send file to IGS for conversion so if IGS is not up and running you should get an RFC error and conversion process will not work.

 

9.jpg10.jpg

11.jpg

 

If Connection Test is succesful than we can say the IGS is up and running.

12.jpg

 

4. Note 454042 - IGS: Installing and Configuring the IGS

 

If IGS is not running than BASIS should apply this note which explains the steps clearly.

 

454042 - IGS: Installing and Configuring the IGS

 

5. Programming Step

 

Some number of approaches can be used to develop this kind of program. As SE78 and similar tcodes work on frontend services like GUI_UPLOAD, I used DATASET logic to handle data uploading and data storing. (Complete source code added at the end of the document.)

I used PNP logical database as I want to fetch Employee Photo. The logic of the program goes like this.

 

13.jpg

 

fetch_and_convert_emp_photo subroutine starts with employee photo check.

 

14.jpg

then we get the binary data for the file

 

15.jpg

then we write the binary file to /usr/sap/trans/ directory

 

16.jpg

 

then we read this file into an xstring typed variable and delete the JPG file from directory. Here I used FM - ZBMP_CREATE_FROM_EXT_FORMAT which gets the xstring file and converts to bitmap.

 

17.jpg

 

Thomas Jung has a nice article about ABAP Bitmap Image Processing Class which tells us about ZCL_ABAP_BITMAP class. This class has a method CREATE_FROM_EXT_FORMAT which this function is derived from.

 

18.jpg

19.jpg

 

The method uses standard components so you may directly create this simple FM instead of Implementing whole ZCL_ABAP_BITMAP and call this FM instead of using ZCL_ABAP_BITMAP class methods.

 

 

Source Code is as follows;

 

FUNCTION ZBMP_CREATE_FROM_EXT_FORMAT.

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

*"*"Local Interface:

*"  IMPORTING

*"     REFERENCE(XSTREAM) TYPE  XSTRING

*"     REFERENCE(FORMAT) TYPE  STRING DEFAULT 'JPG'

*"  EXPORTING

*"     REFERENCE(BITMAP) TYPE  W3MIMETABTYPE

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

 

  DATA: l_igs_imgconv TYPE REF TO cl_igs_image_converter,

         l_img_blob    TYPE w3mimetabtype,

         l_img_size    TYPE w3param-cont_len,

         l_bmp_xstream TYPE xstring.

 

   CREATE OBJECT l_igs_imgconv.

 

   l_img_size = XSTRLEN( xstream ).

 

   CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

     EXPORTING

       buffer     = xstream

     TABLES

       binary_tab = l_img_blob.

 

   CALL METHOD l_igs_imgconv->set_image

     EXPORTING

       blob      = l_img_blob

       blob_size = l_img_size.

 

   DATA l_format TYPE string.

 

   l_format = format.

 

   CASE l_format.

     WHEN 'TIF'.

       l_igs_imgconv->input  = 'image/tiff'.

     WHEN 'JPG'.

       l_igs_imgconv->input  = 'image/jpeg'.

     WHEN 'PNG'.

       l_igs_imgconv->input  = 'image/png'.

     WHEN 'GIF'.

       l_igs_imgconv->input  = 'image/gif'.

     WHEN OTHERS.

       EXIT.

   ENDCASE.

 

   l_igs_imgconv->output = 'image/x-ms-bmp'.

 

   CALL METHOD l_igs_imgconv->execute

     EXCEPTIONS

       OTHERS = 1.

 

   IF sy-subrc IS INITIAL.

 

     CALL METHOD l_igs_imgconv->get_image

       IMPORTING

         blob      = l_img_blob

         blob_size = l_img_size.

 

     CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

       EXPORTING

         input_length = l_img_size

       IMPORTING

         buffer       = l_bmp_xstream

       TABLES

         binary_tab   = l_img_blob

       EXCEPTIONS

         failed       = 1

         OTHERS       = 2.

 

     bitmap = l_img_blob.

 

   ENDIF.

 

ENDFUNCTION.


then we write this converted bitmap file to the same directory like this

 

20.jpg

 

at this point we have the bmp formatted employee photo and can upload this to Document Server. there is the subroutine "import_bitmap_bds " in standard report "saplstxbitmaps" which asks for the user for the file to be uploaded. I converted the subroutine to work with file in usr/sap/trans directory.

 

Here is the modified subroutine;

 

 

FORM import_bitmap_bds_local.

MOVE list_filename TO imagefile.
MOVE pernr-pernr   TO imagename.
MOVE pernr-pernr   TO imagedesc.

DATA: l_resolution  TYPE stxbitmaps-resolution.
DATA: l_docid     TYPE stxbitmaps-docid.

DATA: l_object_key TYPE sbdst_object_key.
DATA: l_tab        TYPE ddobjname.
DATA: BEGIN OF l_bitmap OCCURS 0,
l
(64) TYPE x,
END OF l_bitmap.
DATA: l_filename        TYPE string,
l_bytecount      
TYPE i,
l_bds_bytecount  
TYPE i.
DATA: l_color(1)        TYPE c,
l_width_tw       
TYPE stxbitmaps-widthtw,
l_height_tw      
TYPE stxbitmaps-heighttw,
l_width_pix      
TYPE stxbitmaps-widthpix,
l_height_pix     
TYPE stxbitmaps-heightpix.
DATA: l_bds_object      TYPE REF TO cl_bds_document_set,
l_bds_content    
TYPE sbdst_content,
l_bds_components 
TYPE sbdst_components,
wa_bds_components
TYPE LINE OF sbdst_components,
l_bds_signature  
TYPE sbdst_signature,
wa_bds_signature 
TYPE LINE OF sbdst_signature,
l_bds_properties 
TYPE sbdst_properties,
wa_bds_properties
TYPE LINE OF sbdst_properties.
DATA  wa_stxbitmaps TYPE stxbitmaps.


* Enqueue
PERFORM enqueue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

*** Read BMP File
CLEAR list_filename.
MOVE imagefile TO list_filename.
OPEN DATASET list_filename IN BINARY MODE FOR INPUT.
IF sy-subrc EQ 0.
CLEAR xstr1.
*** Read BMP File
READ DATASET list_filename INTO xstr1.

**** Delete BMP File
DELETE DATASET list_filename.

CLEAR l_bitmap.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer        = xstr1
IMPORTING
output_length
= l_bytecount
TABLES
binary_tab   
= l_bitmap.

CASE sy-subrc.
WHEN 0.
WHEN 2.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.
MESSAGE e811(td) WITH imagefile.

WHEN 3.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.
MESSAGE e812(td) WITH imagefile.

WHEN OTHERS.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

MESSAGE e813(td) WITH imagefile.

ENDCASE.

l_color
= c_true.

* Bitmap conversion
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP_BDS'
EXPORTING
color                    = l_color
format                   = 'BMP'
resident                
= space
bitmap_bytecount        
= l_bytecount
compress_bitmap         
= space
IMPORTING
width_tw                
= l_width_tw
height_tw               
= l_height_tw
width_pix               
= l_width_pix
height_pix              
= l_height_pix
dpi                     
= l_resolution
bds_bytecount           
= l_bds_bytecount
TABLES
bitmap_file             
= l_bitmap
bitmap_file_bds         
= l_bds_content
EXCEPTIONS
format_not_supported    
= 1
no_bmp_file             
= 2
bmperr_invalid_format   
= 3
bmperr_no_colortable    
= 4
bmperr_unsup_compression
= 5
bmperr_corrupt_rle_data 
= 6
OTHERS                   = 7.
IF sy-subrc <> 0.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING conversion_failed.
ENDIF.

* Save bitmap in BDS
CREATE OBJECT l_bds_object.

wa_bds_components
-doc_count  = '1'.
wa_bds_components
-comp_count = '1'.
wa_bds_components
-mimetype   = c_bds_mimetype.
wa_bds_components
-comp_size  = l_bds_bytecount.
APPEND wa_bds_components TO l_bds_components.

IF l_docid IS INITIAL.          " graphic is new

wa_bds_signature
-doc_count = '1'.
APPEND wa_bds_signature TO l_bds_signature.

CALL METHOD l_bds_object->create_with_table
EXPORTING
classname 
= c_bds_classname
classtype 
= c_bds_classtype
components
= l_bds_components
content   
= l_bds_content
CHANGING
signature 
= l_bds_signature
object_key
= l_object_key
EXCEPTIONS
OTHERS     = 1.
IF sy-subrc <> 0.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

MESSAGE e285(td) WITH imagename  'BDS'.

ENDIF.
READ TABLE l_bds_signature INDEX 1 INTO wa_bds_signature
TRANSPORTING doc_id.
IF sy-subrc = 0.
l_docid
= wa_bds_signature-doc_id.
ELSE.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

MESSAGE e285(td) WITH imagename 'BDS'.

ENDIF.

ELSE.                " graphic already exists
********* read object_key for faster access *****
CLEAR l_object_key.
SELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
WHERE tdobject = 'GRAPHICS'
ANDtdid     = 'BMAP'
ANDtdname   = imagename
ANDtdbtype  = 'BCOL'.
SELECT SINGLE tabname FROM bds_locl INTO l_tab
WHERE classname = c_bds_classname
ANDclasstype = c_bds_classtype.
IF sy-subrc = 0.
SELECT SINGLE object_key FROM (l_tab) INTO l_object_key
WHERE loio_id = wa_stxbitmaps-docid+10(32)
ANDclassname = c_bds_classname
ANDclasstype = c_bds_classtype.
ENDIF.
******** read object_key end ********************

CALL METHOD l_bds_object->update_with_table
EXPORTING
classname    
= c_bds_classname
classtype    
= c_bds_classtype
object_key   
= l_object_key
doc_id       
= l_docid
doc_ver_no   
= '1'
doc_var_id   
= '1'
CHANGING
components   
= l_bds_components
content      
= l_bds_content
EXCEPTIONS
nothing_found
= 1
OTHERS        = 2.
IF sy-subrc = 1.   " inconsistency STXBITMAPS - BDS; repeat check in
wa_bds_signature
-doc_count = '1'.
APPEND wa_bds_signature TO l_bds_signature.

CALL METHOD l_bds_object->create_with_table
EXPORTING
classname 
= c_bds_classname
classtype 
= c_bds_classtype
components
= l_bds_components
content   
= l_bds_content
CHANGING
signature 
= l_bds_signature
object_key
= l_object_key
EXCEPTIONS
OTHERS     = 1.
IF sy-subrc <> 0.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

MESSAGE e285(td) WITH imagename 'BDS'.
ENDIF.
READ TABLE l_bds_signature INDEX 1 INTO wa_bds_signature
TRANSPORTING doc_id.
IF sy-subrc = 0.
l_docid
= wa_bds_signature-doc_id.
ELSE.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.
MESSAGE e285(td) WITH imagename 'BDS'.
ENDIF.

ELSEIF sy-subrc = 2.
PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.
MESSAGE e285(td) WITH imagename 'BDS'.
ENDIF.

ENDIF.

* Save bitmap header in STXBITPMAPS
wa_stxbitmaps
-tdname     = imagename.
wa_stxbitmaps
-tdobject   = 'GRAPHICS'.
wa_stxbitmaps
-tdid       = 'BMAP'.
wa_stxbitmaps
-tdbtype    = 'BCOL'.
wa_stxbitmaps
-docid      = l_docid.
wa_stxbitmaps
-widthpix   = l_width_pix.
wa_stxbitmaps
-heightpix  = l_height_pix.
wa_stxbitmaps
-widthtw    = l_width_tw.
wa_stxbitmaps
-heighttw   = l_height_tw.
wa_stxbitmaps
-resolution = l_resolution.
wa_stxbitmaps
-resident   = space.
wa_stxbitmaps
-autoheight = 'X'.
wa_stxbitmaps
-bmcomp     = space.
INSERT INTO stxbitmaps VALUES wa_stxbitmaps.
IF sy-subrc <> 0.
UPDATE stxbitmaps FROM wa_stxbitmaps.
IF sy-subrc <> 0.
MESSAGE e285(td) WITH imagename 'STXBITMAPS'.
ENDIF.
ENDIF.

* Set description in BDS attributes
wa_bds_properties
-prop_name  = 'DESCRIPTION'.
wa_bds_properties
-prop_value = imagedesc.
APPEND wa_bds_properties TO l_bds_properties.

CALL METHOD l_bds_object->change_properties
EXPORTING
classname 
= c_bds_classname
classtype 
= c_bds_classtype
object_key
= l_object_key
doc_id    
= l_docid
doc_ver_no
= '1'
doc_var_id
= '1'
CHANGING
properties
= l_bds_properties
EXCEPTIONS
OTHERS     = 1.

PERFORM dequeue_graphic USING 'GRAPHICS'
imagename
'BMAP'
'BCOL'.

ENDIF.

ENDFORM.                    "import_bitmap_bds_local

 

With the use of this modified subroutine, we can batch upload converted BMP files to Document Server. We can run this report as scheduled job so that it gets the employee photo, converts it to BMP format and uploads it to Document Server.

 

You can find the source code of the sample report as attachment (bitmap automization.txt) to this document.

 

 

Hope this document helps.

 

Murat Kaya - 2014

Reporting Transport request flow in different land scapes

$
0
0



Summary

 

The document briefly explains how to track the transport request flow once released from the development system. We know that once development is completed the changes are saved in a TR and moved to quality systems for further testing prior to production system. The traditional way allows login to each system and manually doing a vlook up after downloading the list of released TRs, which consumes some time. Here we discuss about a new report which can track if the TR is moved to quality and prod systems.

 

Author Bio


Author(s): Rahul Babukuttan, having around 5 years of SAP experience.

SAP Certified ABAP Consultant. Completed M-Tech in Networking Technologies

 

Created on: 12 December 2014

 

 

Table of Contents

Introduction

Background

Assumptions

How to fetch TR details from SAP tables

How to identify TR is moved to Quality/Production system

References

 

 

Introduction

 

The new report allows user to search the TR using date, username, TR number or TR description. The report provides the output of all the TRs in the selection criteria and the position in which system the TR currently resides. The output can be displayed as alv report with traffic lights say red if it have not reached production. Advantage is that we can mail the report output if SCOT is properly configured.

 

Background

 

Once a TR is created in the system an entry will be created in E070 and E071 tables. When a TR is in released status, a datafile and cofile is created by the system and is stored at OS level.

 

In a project having some 100s of TRs to be created and moved in a bulk to quality and production system. The standard se01 transaction allows finding the list of a particular user or TR number. There is no standard reporting tool to find track the position of TR movement in a bulk based on user or based on specific date criteria. The traditional way is that the basis team needs to login to each system and download the list as excel and to a vlook up to find the difference or to identify if the TR reached till quality and not to production system.

 

Assumptions

 

1. This is applied only for released TRs.

2. The input in consideration is only TR number and not the Task number

3. The user who is executing the report is provided with all the required authorizations

4. In the document the assumption is TR is created in development system RD0, then moved to quality RQ0 and then to production RP0. The flow will be RD0->RQ0->RP0.

5. There is no need to transport this report say ZTR_CHECK to any systems say RQ0 or RP0 since the code explained below can retrieve all the data in quality and production systems.

 

How to fetch TR details from SAP tables

 

Normally all the TR numbers, type of TR say work bench or customizing TR, the status(released or not), Owner of TR will be stored in the SAP table E070. The description will be stored in the table E07T.

 

1. If our search is based on date/username/TR number first fetch the records from table E070 and then from E07T for getting description

 

SELECT * FROM E070 INTO T_E070

WHERE trkorr in s_trkorr[]

AND trfunction in (‘K’, ‘W’)

AND trstatus in (‘R’,’N’)

AND as4user in s_user[]

AND as4date in s_date[].

 

IF T_E070[] is not initial.

SELECT * FROM E07T INTO TABLE T_E07T

FOR ALL ENTRIES IN T_E070

where TRKORR = T_E070-TRKORR

AND AS4TEXT LIKE ----------->>>>(concatenated value of ‘% ‘ P_TEXT).

Endif.

 

2. If the search is based on TR description first get records from E07T and then from E070 table.

 

How to identify TR is moved to Quality/Production system

 

We can do this by either of two methods. The first method can be used if the quality and prod systems are under same transport group. The second method is preferred if we are having a system with different transport group.

 

If Quality and Prod are under same Transport Group

 

Call the FM STRF_READ_COFILE, passing the TR number as parameter. The fm will output an internal table TT_COFI_LINES

 

  1. In the internal table explained above, we can see the fields TARSYSTEM and FUNCTION.
  2. The TARSYSTEM stands for the target system where if the TR is moved. For example if the TR is moved in RQ0, then the FM will return the internal table with target sytem as RQ0
  3. If the TR is moved successfully, the field FUNCTION in the internal table will have the value “I”(Imported).
  4. There are some other relevant fields like Date/Time/Return Code

 

However, I have seen a couple of cases like the FM return exceptions. If in case if the cofile is deleted by basis, it will throw info not found exception

 

If Quality and Prod are under different Transport Group

 

There are some cases where we can see some systems say RH0 which have a different transport group. We can see in depth in SMTS transaction.  In such cases, the above FM cannot help in providing much clarity about the TRs. Hence we search this by an alternate method provided we have properly configured a logical destination in the transaction SM59 between RD0 and RH0. We assume that the logical destination name is RH0CLNT700. Maintaining logical destination between different system/client is out of the scope of the document.

 

  1. Call the FM RFC_READ_TABLE destination ‘RH0CLNT700’.
  2. Pass the query table value as ‘E070’. If the TR is transported to RH0, an entry will be created in the table E070.
  3. Also pass the value of internal table “options”. For example, if the TR I need to be checked is  RD12345, the itab options should be populated as    concatenate ‘TRKORR’ ‘=’ ‘’’’ into l_string separated by space.

       CONCATENATE l_string ‘RD12345’ ‘’’’ INTO l_string.

       MOVE l_string to l_str_option-text.

       APPEND  l_str_option TO l_tab_option

   4. Pass the value of fields to be fetched in itab L_TAB_FIELDS.                                                    

For example Append ‘TRKORR’ to L_TAB_FIELDS. Append AS4TIM to L_TAB_FIELDS.

    5.The FM returns the internal table T_DATA which contains the corresponding entry in RH0 from table E070. If an entry is present means that the TR is     moved. Otherwise the TR is not moved at all.

 

Build Final internal table

 

Once we fetched all the required data, we can loop the internal table and read all the required data in stages for all the target systems. If the read is successful for all the target systems say RD0/RH0/RQ0/RP0 we can mark that entry as SAFE/ Green. If the read is failed in any of the target systems means that the TR is missed some where and can mark as RED.  Call the FM REUSE_ALV_GRID_DISPLAY with traffic lights on will display a report and easily find out where the TR is stuck.

 

References

 

http://wiki.scn.sap.com/wiki/display/ABAP/Transport+Dependency+Utilities

http://scn.sap.com/thread/1150564

http://www.newtosap.info/2013/04/traffic-lights-display-icons-in-alv.html

http://scn.sap.com/thread/584482

Viewing all 935 articles
Browse latest View live


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