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

Automate distribution of quantity in MIGO

$
0
0

Requirement:

With respect to a production order AUTOMATE the distribution of quantity (basically split production order quantity) and assign batch numbers from an existing ztable to each line split while doing a Goods Receipt with reference to a production order.

 

Prerequisite:

  1. Make sure that the automatic batch creation setting in Production Scheduling profile has been turned-off so that the Production order batches are created only through the enhancement framework. (this is customizing setting and is to be made by Functional consultant)
  2. Implement enhancement from document 'Creating Multiple batches for a Production order' there by creating multiple batches for a production order (Optional if you do not wish to have multiple batches and only want to distribute quantity automatically where in u just have to implement the enhancement to split the quantity based on some criteria)
  3. Production order batches are available in a ztable. Here i am using database table 'ZPROD_BATCHES' with below fields.(Optional if you do not wish to have multiple batches and only want to distribute quantity automatically where in u just have to implement the enhancement to split the quantity based on some criteria)

          Capture2.PNG

 

Issue:

The standard functionality in SAP is to manually distribute the quantity by clicking on the button distribute quantity. There is no automation by default, so an enhancment in the standard functionality is needed to meet the requirement.

 

Below screenshots shows the manual process of distributing the quantity, and the solution part of this document explains the enhancement to achieve automation of quantity distribution.

 

Go to T-code MIGO  -> Select operation GOODS RECEIPT -> Select reference document as ORDER -> then Production order number, it will display the details related to the production order

Capture2.PNG

After you click on the Distribute Qty button a new window will popup asking for manual distribution of quantity where you have to enter the quantity and other information for each single line based on the number of lines you want to distribute the production order quantity. the screen shot below shows the same by distributing the production order quantity into 2 lines.

Capture2.PNG

once u have done distributing the quantity and batch assignment, clicking on 'ADOPT' button will adopt the changes in the goods receipt and the quantity will be distributed accordingly as below.

 

Capture2.PNG

 

Solution :  

 

Although there can be many possible solutions to this but the the one that worked out for me is documented here. This solution in specific deals with the process of automation of quantity distribution along with the newly created batch number assignment (to the distributed quantity) from a ztable while doing Goods Receipt in MIGO with reference to a production order, but in general can also be used to distribute the quantity automatically and eliminate the manual steps.

 

Note:

Enhancement Section, Spots and their respective implementation knowledge is necessary for this. Information like what is it and how to implement it can be found online. For those who have no knowlegde on the new enhancment framework, i suggest you go through the documentation available online and familiarize yourself with the features and process related to it. 

 

The default logic with respect to the manual process of distribute quantity button is written in an enhancement-section 'POPUP_CALL_03' of include 'LMIGOSP3', see below screenshot for reference. This logic handles default SAP process.

Capture2.PNG

To automate the quantity distribution we have to enhance the current logic, so create an implementation for the enhancement-section 'POPUP_CALL_03'.

one important thing to note with the enhancement-section is that when you try to implement a new logic for it, you are actually replacing the existing default logic (it was having earlier) with a new logic. so the existing logic is deactivated and the new implementation you just created will hold the logic from the deactivated code (which is proposed in the new implementation by default). Now it is up to you to decide whether to keep the proposed code along with your new code or to remove the proposed code and only add your new code. It may not be clear at this point of time but once you start creating an implementation for the enhancement-section you will understand what i am trying to say.

 

So create an implementation for the enhancement-section 'POPUP_CALL_03', following which the system proposes the default code.

 

In this scenario we need the proposed code so we add the proposed code to the else part of an IF-ELSE condition as below.

Capture2.PNG

With the proposed code in the else part you can write your new logic in the if part where the if condition holds your criteria for executing the logic. This enhancement is generic to most of the operations in MIGO so make sure to add in checks for the type of MIGO operation (Goods receipt / Goods issue etc) and reference document type (Order / Purchase order etc) . Also this enhancement will have global effect so do not forget to add checks on the specific palnt or any other criteria, whichever is suitable based on the requirement.

 

So in this scenario ideally the IF condition should hold the following checks.

IF  GODYNPRO-ACTION = 'A01' (Goods receipt) AND GODYNPRO-REFDOC = 'R08' (Order) AND GOITEM-WERKS = 'XYZ'.

(GODYNPRO and GOITEM are structures available at this point in the program and hold relevant information of the process.)

Adding the above checks will ensure that the enhancment will not be executed for other MIGO operations and other reference document type. for others the else part comes in to picture which holds the default (proposed) code from SAP.

 

In this scenario the quantity has to be distributed based on the number of records available for the production order in table ZPROD_BATCHES, Only part left out is to fetch the relevant production order data into an internal table from the table ZPROD_BATCHES, and then for every relevant production order record in the table ZPROD_BATCHES, fill the internal table 'PT_GOSPLIT' with the distributed quantity and append the records. The code below gives you an exact picture of what i am trying to say.

 

************ Start of implementation ************

 

   DATA : ta_gosplit TYPE STANDARD TABLE OF gosplit,
                wa_gosplit TYPE gosplit.

 

   DATA : ta_pobatch TYPE STANDARD TABLE OF zprod_batches,
                wa_pobatch TYPE zprod_batches.

 

 

IF  GODYNPRO-ACTION = 'A01' AND GODYNPRO-REFDOC = 'R08' AND GOITEM-WERKS = 'XYZ'. "XYZ= plant name

 

   SELECT * FROM zprod_batchesINTO TABLE ta_pobatch WHERE aufnr = goitem-pps_aufnr. "goitem-pps_aufnr = production order number

 

      LOOP AT ta_pobatch INTO wa_pobatch.
           wa_gosplit-lgort = goitem-lgort.
           wa_gosplit-charg = wa_pobatch-charg.
           wa_gosplit-bwart = goitem-bwart.
           wa_gosplit-erfmg = wa_pobatch-bdmng.
           wa_gosplit-erfme = wa_pobatch-meins.
           wa_gosplit-lgobe = goitem-lgobe.
           wa_gosplit-split_line = sy-tabix.
           APPEND wa_gosplit TO ta_gosplit.
           CLEAR wa_pobatch.
    ENDLOOP.
    IF NOT ta_gosplit IS INITIAL.
      pt_gosplit = ta_gosplit.
      REFRESH : ta_pobatch, ta_gosplit.
    ENDIF.

 

ELSE.

* Below is the existing functionality from the enhancemnt section POPUP_CALL_03  in the else part (proposed code) as illustrated earlier in this document.

Capture2.PNG

ENDIF.

************End of implementation*****************

 

After activating the enhancement implementation, for MIGO operation with GOODS RECEIPT and reference order ORDER of plant 'XYZ' will have the automated distribution of quantity based on the ztable ZPROD_BATCHES. The rest of all the MIGO operations will hold Standard SAP functionality.

The enhanced feature of the MIGO transaction is demonstrated below.

 

Go to T-code MIGO  -> Select operation GOODS RECEIPT -> Select reference document as ORDER -> then Production order number of palnt XYZ, it will display the details related to the production order

Capture2.PNG

Click on the Distribute Qty button. earlier it used to display a popup window to manually distribute the quantity. But after the new enhancement popup window is supressed and the quantity is distributed automatically based on the data from the ztable.

Capture2.PNG

 

Here the automation aspect is to avoid manual search for the production order batches and the line split quantity by implementing the enhancement to fetch the relevant data from the concerned ztable and populate it by default for production orders from plant XYZ.

 

*****************************************************THE END********************************************************


Automation.. lessons learnt !!!

$
0
0

     Ask a layman what he understands by "Automation" and the most expected answer is "Doing something automatically" .

     Right!!! When something is done without the intervention of a human, it is automation. And how would you answer "Why automation?”Is it because we trust the machines more than humans or because machines can work tirelessly or because they can do the same job tenfold faster?

The answer is "All of it and much more”.

     Automation helps us with all of this. But keep in mind that we are humans, and 'it is human to err'. What if the creator of this unit of automation (in our context the automated script) does it the wrong way? The “wrong” would also get multiplied and multiply faster than we can realize something is not right. The whole idea is to do it the right way, and in the very beginning itself. It is those small things we ignore in the initial stages which later manifest as huge problems when the automation happens at a large scale. Everything multiplies, including the mistakes we have done and it becomes very difficult to correct it.

This is one of the reasons why some people still prefer manual testing, as they think more time goes in the maintenance and the correction of scripts in addition to their creation and execution.

     The power of automation has always been undermined because of the lack of being organized, structured and methodical in its creation. An automated script is best utilized when it is most reliable and re-usable. These two factors contribute towards easy execution (once the scripts are ready), maintenance (whenever there's a change in application) and accuracy of results (when the scripts get executed).

 

     A reliable script can be created only when the tester has a good understanding of the application, its usage and the configurations behind it. This requires a lot of reading and investigation of the application to know how it behaves under a given circumstance. Once this is done, the script can be created such that it handles the application for all possible application flow.

 

     A reusable script truly defines the meaning and purpose of automation. With a perfectly reusable script, further automation of upcoming applications becomes easier and faster. Maintenance is another take away from this attribute of a script. Reusability is a result of standardization of a script in all aspects like structure and naming convention. Let us look at them individually and see how they add to the script’s reusability.

 

Structure of an automated script: A well-structured script becomes easy to understand and adapt especially to those who take it over from others. It makes the script crisp without any unwanted coding. It is important to strictly limit the script to its purpose and keep only the absolute necessary.

For example, when it comes to validation part, which can be done in many ways (message check, status check, table check, field check and so on) it might not be required for every case. Also remember that a DB Table check takes extra efforts from the script to connect to the system and read the table. One execution may not make a difference, but on a large scale execution, it – does – matter. 

 

Such additional coding needs to be identified and eliminated. Let us analyze the necessary coding according to the purpose of the test:

1.      Functional Correctness: Validation is required before and after the execution of the application to see how the transaction has affected the existing data.

                         Validation before test --> Execution of tcode under test  --> Validation after test

2.      Performance Measurement: Performance is considered only after the application has been tested for its functional correctness. Validation has no purpose here as the focus of test is non-functional

         Execution of tcode under test

3.      Creation of Data for Performance: Usually massive data is required for Performance measurement.

      For e.g. a 1000 customers with 150 line items each… the same could be repeated for vendors, cost centers, and so on. Table checks on this scale of execution would create a huge load on the system and it would take hours to create such data, may be even days in some cases. It is best to avoid validation/table reads of any kind. Another point to keep in mind here is that using a functional module or a BAPI to create data saves a lot of time and effort. A TCD recording or a SAPGUI recoding should only be the last option.

                        Execution of tcode for data creation --> Validation after test

4.      Creation of data for system Setup: this is usually done on a fresh system, with no data. Hence verification only at the end would suffice.

                         Execution of tcode for data creation --> Validation after test

 

There is also a subtle aspect of being structured…  The Naming Convention.

Testers usually tend to name their script to suit their need, ignoring the fact that these transactions can be used by anyone in an integrated environment. Searching for existing scripts becomes easy when proper rules are followed while naming them. It may happen that more than one script exist for the same purpose, such duplication has to be avoided. Attributes like the purpose (unit or integration testing or customizing or performance), tcode executed, action (change or create or delete), release need to be kept in mind while setting up the rules.

The same goes for Parameters as well. Work becomes easy while binding the called script and the calling script (script references). Also quick log analysis is another take away from common naming conventions for parameter.

There is another factor that makes automation more meaningful and complete in all sense. That is documentation. Documentation is a record of what exactly is expected of the script. Its importance is realized at the time of hand over, maintenance and adaptation. However ‘Document Creation’ itself can be dealt with as a separate topic. The idea is that document creation should not be disregarded as unimportant.

Having done all this, we need to watch out for the scope of test. With new functionality getting developed over the older ones (e.g. enhancement of features), re-prioritization needs to be done regularly. Old functionality may not be relevant anymore or they must be stable enough to be omitted from the focus topics. This way the new features/developments get tested better.

Now let us summarize the write up. All the aspects mentioned above are not something we cannot do without. Automation can still happen without any of these factors. However, the benefits we draw from them can make a huge difference on time and efforts of both automation and maintenance. Understanding a script authored by someone else, Knowledge transfer, Adaptation, Corrections... these are just a few advantages to list down.

The world of automation is very vast and its benefits still remain unexplored.

BDC for CU51 / CU50

$
0
0

Hi Folks,

 

Long back I was given the requirement to develop a Function Module for operations in Order BoM Configuration Results (CU51) i.e. Insert, Copy, Delete and Change. After a good amount of search output was nothing due to which I tried my last option of BDC for that which was giving random results.

 

It was a challenging task for me to get out of CU51 successfully with a solution, after healthy discussions with my team we came to conclusion and a good logic to fulfill the requirements to a certain extent.

 

 

About

This document is meant to provide the solution of operations like Insert, Copy, Delete etc. on Order BoM in CU50 or CU51 in Configuration Result screen

 

Version 1.00

SAP Release

SAP ERP 6.0 EHP6

Transaction Code

CU51 / CU50

 

 

1 Scope

This document gives a raw solution with code snippet to Order BoM Configuration Results toolbar operations (CU51) via BDC/FM.

These operations include only Change, Delete, Copy, Insert.

 

2 Prerequisites

Following are the major prerequisites to be taken care before implementing the solution to your system.

  • SAP Component Version compatibility
  • SAP implementations for SD, PP

 

3 What are CU51 operations

CU51 is one of the transaction codes used for Order Bill of Materials in SAP. Through this functionality we can also view or change Configuration Results of the material in Order BoM.

After getting on to configuration results screen we have multiple operations to do like we can insert a new item, change the existing item, copy and delete the existing ones.

That item can be a Compatible unit, Document, Non stock, Stock, Text or Variable size item.

Following are the operations we are going to discuss in this document.

  • Insert
  • Change
  • Copy
  • Delete

 

4 How we do it manually

Let us discuss the current process for the above mentioned operations with the help of appropriate screen shots.

All the operations are similar to each other in their approach so we will discuss only one in detail so that it can be taken as reference for others.

 

Operations_CU51.JPG

 

 

4.1 Delete

We will follow a generic process for the operation.

  • Go to command bar on top left and enter ‘CU51’
  • Now you will see Order BoM: Initial Screen, enter the order number and order item as shown in the screen shot below and press enter

del1.jpg

 

  • Click on ‘Results’ button (Ctrl+F9), now you will see all the configuration results on next screen as shown below

del2.jpg

  • Go to ‘Edit’ on menu bar and select ‘Select All’ as shown

del3.jpg

  • Now click on compress button, after which you will see  all the nodes getting collapsed or compressed
  • Now select the node under which you want to perform given operation as shown

del4.jpg

  • Now click on explode button after which you will see that node gets collapsed into it’s sub items,  now select the sub node you want to delete

del5.jpg

  • Now click on delete button and then click on save button to save the changes made

 

4.2 Change/Copy/Insert

Now similarly we can perform all other operations as well.

 

5 How SAP standard is updating

SAP is updating the database via Update mode Function Module BOM_POST inside another FM CS_BT_BOM_POST in include program LCSSFU01.


As per my understanding there is no standard class or function module or bapi is available for these operations.

 

6 Why we want this solution

As I said there is no such FM or class available for all these operations so the final option is nothing but Batch Input which is a bit complex in itself.

When I was given this requirement I thought it will be like any other process in which we will use standard FM or program to update but I didn’t find any such program which was a bit strange, then I moved on towards Batch Input which itself was a challenge to implement and after a bit of struggle I was able to get a raw solution for the same and it’s working fine as per the requirements given to me.

 

Sometimes we face such instances that we need to update the data via back end FM or class for customized applications on GUI or Web interface as per the customer requirements, at that point of time we can implement the given solution

 

7 Assumptions

Well it’s not a perfect solution but we can still make it useful for many such requirements, it’s being implemented with certain assumptions mentioned below.

  • When compressing all nodes, visible nodes are header nodes(black color) and after expansion we get item nodes(blue color)

nodes.jpg

  • Internal table for BDC needs to be in same sequence as in standard with proper indexing keeping in mind the header and item nodes, like other columns need to be added which will contain the header node and item node calculated programmatically (Will demonstrate in example)
  • On updating the long text taken as input, first two lines need to be empty spaced and the text should start from 3rd line as shown in the screen shots below

ltext1.jpg

ltext2.jpg

 

  • Operations will be performed in fixed sequence i.e. Change, Delete, Copy and Insert
  • At once only 4 header nodes can be seen on screen and item nodes will vary based on the selected header node, it may vary from minimum 1 item node to maximum 4 item nodes

 

8 Solution

  • We will record individual BDC recording for every operation
  • We will calculate the formula for selecting the header node based on the last assumption and input index in the internal table, similarly we will calculate the no of page downs to be done to select the required header node
  • Based on the last assumption, selected header node and item nodes displaying on screen after expanding the selected header node, we will calculate the page downs for item node and index of item node to be selected
  • Now we will perform the operation
  • If the operation is delete or copy we will have to pro-grammatically reorder the index of next nodes for other operations
  • Once all the operations with correct reordering is done we will save the changes

 

8.1    Raw Code Snippet and Screen shots


Following are the parameters of the FM and code is attached in the text files.

Please ignore the unwanted code if it's not required.


Importing Parameters

import.jpg


Table Parameters

tables.png


 

Structure ZCU51_INP

 

Field name

Types

Data element

Data type

Length

Decimal

Description

H_ITM

1 Types

EBELP

NUMC

5

0

Header Node Index

S_ITEM

1 Types

EBELP

NUMC

5

0

Item Node Index

C_H_ITM

1 Types

EBELP

NUMC

5

0

Sub header index (Header node index to be selected, only for Copy operation)

C_S_ITEM

1 Types

EBELP

NUMC

5

0

Sub Item index (Item node index index
to be copied, only for copy operation)

ICD_IND

1 Types

ZCU51_ICD_IND

CHAR

1

0

Change/Delete/Copy/Insert Indicator

MATNR

1 Types

MATNR

CHAR

18

0

Material Number

POSNR

1 Types

SPOSN

CHAR

4

0

BOM Item Number

POSTP

1 Types

POSTP

CHAR

1

0

Item Category (Bill of Material)

STLKN

1 Types

STLKN

NUMC

8

0

BOM item node number

IDNRK

1 Types

IDNRK

CHAR

18

0

BOM component

MENGE

1 Types

KMPMG

QUAN

13

3

Component quantity

MEINS

1 Types

KMPME

UNIT

3

0

Component unit of measure

FMENG

1 Types

FMNGE

CHAR

1

0

Fixed qty

AVOAU

1 Types

AVOAU

DEC

5

2

Operation scrap

AUSCH

1 Types

KAUSF

DEC

5

2

Component scrap in percent

NETAU

1 Types

NETAU

CHAR

1

0

Indicator: Net scrap

POTX1

1 Types

POTX1

CHAR

40

0

BOM Item Text (Line 1)

DOKNR

1 Types

DOKNR

CHAR

25

0

Document number

DOKAR

1 Types

DOKAR

CHAR

3

0

Document Type

DOKTL

1 Types

DOKTL_D

CHAR

3

0

Document Part

DOKVR

1 Types

DOKVR

CHAR

2

0

Document Version

PREIS

1 Types

CPREI

CURR

11

2

Price

WAERS

1 Types

WAERS

CUKY

5

0

Currency Key

PENIH

1 Types

PEINH

DEC

5

0

Price Unit

EKORG

1 Types

EKORG

CHAR

4

0

Purchasing Organization

EKGRP

1 Types

EKGRP

CHAR

3

0

Purchasing Group

MATKL

1 Types

MATKL

CHAR

9

0

Material Group

ROMS1

1 Types

ROMS1

QUAN

13

3

Size 1

ROMEI

1 Types

ROMEI

UNIT

3

0

Unit of measure for sizes 1 to 3

ROANZ

1 Types

CS_ROANZ_V

QUAN

13

3

Number of Variable-Size Items

ROAME

1 Types

ROAME

UNIT

3

0

Unit of measure for variable-size items

 

9 Error Handling

 

Following are the possible points to be checked if any error strikes.

  • No enhancements are being done on the screens used
  • Sequence of operations is correct
  • Formula used in the BDC is correct as given in the code snippet
  • Index in the input table are correct

 

10 Example Data

 

test_data.jpg

 

I = Insert, C = Change,  D = Delete,  R = Copy

 

Note: In case of copy C_H_Item = Index of header node to be selected and C_S_Item = Index of item node to be copied. Numbers displayed are index of Header and Item nodes.

Also remaining fields are optional based on the requirements.

 

Suggestions and doubts invited.

 

Thanks and Regards.

How to Find attachments in SAP documents.....!!!

$
0
0

* To check if the document contains any attachments. *

 

In many scenario we need to check if the document contains any attachments and I have also explored and found one function module which works for all documents types.

The name of function module is ARCHIV_GET_CONNECTIONS

 

1. To check if Purchase order contains any attachment.

  • Execute Function module ARCHIV_GET_CONNECTIONS in transaction code SE37
  • Pass Purchase order number 2454358315 as OBJECT_ID

 

1.png

  • Press Execute (F8)
  • You can see as shown in below snap shot marked in yellow color count is 1. It means that the document contains an attachment.

2.png

·  If you click on CONNECTIONS internal Table It will gives you the details about attached document type here it is word doc in purchase order as shown in below snap shot.

3.png

   2.  To check if Purchase Requisition contains any attachment.

  • Execute Function module ARCHIV_GET_CONNECTIONS in transaction code SE37
  • Pass Purchase Req number 2080014745 as OBJECT_ID

 

4.png

  • Press Execute (F8)
  • You can see as shown in below snap shot marked in yellow color count is 3. It means that the document contains three attachments.

5.png

  • If you click on CONNECTIONS internal Table It gives the details about attached document type here it is word doc,xls and PDF in purchase requisition as shown in below snap shot.

6.png

If you want to find all the Purchase orders which have attachments then you can use the FM as shown in below snap shot.

Pass EKKO table name as OBJECTTYPE

7.png

Execte(F8). It will give all the PO which contains attachment.

8.png

In similar way you can pass the table name as OBJECTTYPE to this FM. It will give you that total attached documents.

Generic Program for Table Update

$
0
0

To update transparent database tables, ‘create entries’ option in transaction SE11, or creating and using a table maintenance generator for tables, or creating custom programs could be used. However, using ‘create entries’ or maintenance generator, are ineffective techniques when the number of entries is large; and though creation of custom programs results in faster validating and updating, a single program generally caters to one or some tables, therefore are inflexible.

 

Our business client supplied agile requirements, thus requiring us to constantly create or update custom tables, which led to a substantial time being invested in maintaining such tables or creating/modifying custom programs made for updating large number of entries in tables. Hence, there was a necessity to provide a solution to this agile framework where tables of varying structures would be easily updated.

 

A generic program allowing validation and maintenance of table of any structure would have 4 essential components:

  1. Creation of dynamic internal table at run time utilizing the structure of user defined table name.
  2. Generating a template based on the table structure.
  3. Fetching the domains for every filed in table, determining if it contains a value table or fixed values maintained, and validating all records from fetched data.
  4. Calculating the field-address (row and column number) of the data elements that fail validation and reporting the same. 

 

1. Dynamic Internal Structures

To achieve a dynamic structure that assumes a definite shape at run-time, use of generic field-symbols of type ‘standard tables’ for internal tables and type ‘any’ for work areas.

CREATE DATA lr_table TYPE STANDARD TABLE of (p_tname).

ASSIGN lr_table TO <fs_table>.


2. Generating Template

Step 1: Create an internal table (say table B) with each field being of type string, and having the same number of fields as that of the user specified table, using the same dynamic table creation process as described above. Let the field names be numeric values (1, 2, 3…).

Step 2: Loop through the table containing field level information of table A. Within the loop assign the corresponding fields to a field symbol. Populate this field symbol with the name of the field of table A. Hence, once the loop is complete, all the fields of a single work area contain the names of the fields of table A.

LOOP AT dd_fields INTO ls_ddfields.

     ASSIGN COMPONENT sy-tabix OF STRUCTURE <fs_area2> TO <fs_value>.

         <fs_value> = ls_ddfields-fieldname.

    ENDLOOP.

    APPEND <fs_area2> TO <fs_table2>.

5.png

Step 3: Append this work area to table B and download it on the path specified by user.

 

3. Validating Data

Step 1: Fetch the domain level information for the domains of all fields of the table to be updated. This could be achieved by using standard SAP functionalities. For instance, function module DD_DOMA_GET or standard tables like DD01L and DD07L could directly be used.

Step 2: Loop through every field of the table, and fetch its domain level information into work area. Check if a value table exists for the domain. If a value table exists, create dynamic internal table for the value table.

Step 3: Read through the structure of the value table to fetch for the first field whose domain is the same domain whose value table is referred. This field would contain the check values. Fetch data from value table into an internal table. Loop through all the records uploaded by the user, and validate the field value against the value table values.

Step 4: If no value table exists for the domain, fetch the fixed values checks maintained for the domain through table DD07L. If no values are fetched, it implies that the domain does not have a restriction on the data it takes. If entries are fetched, loop through the records uploaded by the user, and validate the field against the fetched values.

 

 

4. Reporting Validation Fail or Updating Table

Step 1: While updating entries from an excel sheet, a user could be prompted with the cell numbers of the data that failed validation. Since the rows in excel are numeric while columns are alphabetical, reporting the cell column and row in the same format eases in identifying the fail.

The row count can be achieved by calculating the iteration while looping through uploaded data. For generating the column name, following can be used:

 

  DATA: lv_string TYPE string,
       lv_col   
TYPE c,
      
m         TYPE i.

      lv_string 
= sy-abcde.
     
IF n < 26. "n is the iteration number while loooping on the records uploaded
           lv_col
= lv_string+n(1).
           lv_alpha
= lv_col.
     
ELSE.
          m = n DIV 26.
          
m = m - 1.
           lv_col
= lv_string+m(1).
           lv_alpha
= lv_col.
          
m = n MOD 26.
           lv_col
= lv_string+m(1).
          
CONCATENATE lv_alpha lv_col INTO lv_alpha.
     
ENDIF.

SMARTFORMS using BIDIRECTIONAL LANGUAGES

$
0
0

Requirement: We have a current requirement where we need to print both ENGLISH and ARABIC texts and numerals in the same output form for Purchase Orders, Sales Orders, and Invoices etc.

 

Issue Faced:The smart forms while getting printed either shows the Arabic texts in jumbled format (when the print parameter passed is ‘EN’) or it shows all the numerals in Arabic (when the print parameter passed is ‘AR’).

 

Solution: We need to have the following things in place for printing bidirectional language texts (both fixed and dynamic) [in our case the languages being English – Left to Right (LTR) and Arabic – Right to Left (RTL)] in the same form printout:

 

  1. Create the form in Arabic language.

1st.png

 

b. Create all the windows as mirror image of what is the actual output (for example you want a window to appear in the form output to the left topmost      corner – so define it at the right topmost corner and vice versa.)

     2nd.png

     Here the page window is defined at the left lowermost part so that the page numberis printed at the rightmost lower corner.

     3rd.png

c.     Pass the control print parameter language as ‘A’.

 

 

4th.png

d.     Declare all numerals which you want to get displayed in English as dynamic texts.

       Before the declaration as dynamic text the output is as follows:

5th.png

     If you have a look at the left hand window, we see that the text is coming in English but the numerals are in Arabic.

    After using dynamic text the numerals are now coming in English:

6th.png

 

    So now we need to know, how to go ahead with using dynamic texts in Smart Forms:

    Let us take an example where we print the page number as

    Page <Page number> of <Total Page Count>.

    Step 1: Declare a variable of type TSFTEXT.

7th.png

    Step 2: Declare a window for the Page number:

8th.png

There is a text defined and a code piece.

  Step3: Text is defined as follows:

9th.png

Step4: The code part is used to populate FNAME:

10th.png

 

Now the page number is displayed as follows:

11th.png

Synchronising custom programs across system landscape as part of housekeeping activity

$
0
0

Sometimes as part of housekeeping activity we need to bring the custom programs/ function modules in synch with the Production System across all the SAP Boxes in the landscape.

 

Here, I give a brief overview of how that can be implemented with a custom program.

The custom program can be developed following the given steps:

 

a.     Create a program which takes a custom Progam or Custom Function Module name as input (we can later on enhance the program to be able to synchorise for         other objects). Here we take an example where we provide the custom function module - ZASTERIDOC_CREATE_REQ_MATMAS_M which is used as an                        example to bring  the versions in synch.

 

Inside the program the logic needs to be built up in the following lines:

 

b.     Read table VRSD with the object type and the object name:

image1.jpg

 

        We get the Transport Request numbers against each version.

        We sort the table in the descending order by date and time so that we start with the latest transport.

 

c.     Now we need to check the presence of the transports in QUAL/PRD system by using the FM: STRF_READ_COFILE, in the descending order.

        Here in this case, as we run the FM for the transport : DE3K9A00AR, we see that the cofile has the entries for both Quality and Production

        image2.png

          image3.png

       Thus we now know that this version is present in all the systems and is the latest version.

       If it is not present then we will not get the cofile entries.We can then check with the next to the latest TR.

 

d.    When we get to a TR which holds for the Quality or the Prod system and we want to synchronize them, we can then again refer back to the entries of the            VRSD table and check for the relevant version depending on the TR.

 

e.     As we get the OBJECTNAME, OBJECT TYPE and the version number we can use the SUBMIT the values to the program RSEDTVE1, thus reverting back          the programs to the active version in PRD.

 


Hyperlink in Standard Text

$
0
0

Hello Guys,

 

I would be explaining you a peculiar scenario that I have come across

during a Function Module development.

It is about creating hyperlinks in standard texts.

We had a requirement wherein the Portal Team had to trigger an application

which inturn will call a Function Module and a mail will be triggered to the user once his ID is created in the Portal Team.

 

This Function Module was calling the Standard Text.

We had to develop a logic/include hyperlink in the standard text in such a way that when a mail is triggered

to the user there should be a hyperlink available [eg.www.xxxxx.com] so that it would be very easy for him to click on that link

which would inturn take him to the particular website/email address.

 

Steps

  

 

1. To create a Text in Hypertext Modules, go to Transaction SO72.
     Give a name in the Document tab and CREATE.

     [The name given is ZDEMO_TEXT].

 

2.  Go to Menu -> Goto -> Change Editor.

 

3.   Enter the name of the website/link that needs to appear as
     hyperlink and save it.

     [The website/link given is www.heinekenbrouwerijen.nl]

 

4.  Go to the respective standard text in transaction SO10
     with the corresponding TEXT ID and Language.

     [The name of the standard text is 'ZHHU_TEXT']

    

     Go to Menu -> Insert ->Text ->Hypertext.

 

5. Enter the text name [created in S072] and Language

     with the check box->[Expand Immediately] ticked.

 

6. It will automatically include the text that was saved in

    Transaction SO72 with the predefined style

     'S_DOCUS1'.

 

7. The hyperlink is now enabled.

 

8. On clicking the Hyperlink ‘www.heinekenbrouwerijen.nl’ it takes
    you to the respected website [www.heinekenbrouwerijen.nl].

 

Thanks and Regards,

Supreeth M S

SAP ABAP Consultant

  

 

 


How to use C code via FBSL inside ABAP

$
0
0

Hello community,

 

a few month ago I presented here (How to use FBSL inside ABAP) and here (FBSL in the Context of the SAP Application Server) Freestyle BASIC Script Language (FBSL). The actual release candidate of FBSL integrates a dynamic C JIT compiler, so is it possible to use ANSI C code inside FBSL. And with FBSLX, a COM library, you can use FBSL inside ABAP.

 

Here an example how to use ANSI C inside ABAP.

 

"-Begin-----------------------------------------------------------------

  Program zCMandelbrot.

 

    "-Constants---------------------------------------------------------

      Constants CrLf(2) Type c Value %_CR_LF.

      Constants SW_SHOWNORMAL Type i Value 1.

      Constants FbslFileName Type String Value 'zCMandelbrot.fbs'.

 

    "-Variables---------------------------------------------------------

      Data oFBSL Type OLE2_OBJECT.

      Data Buffer Type String Value ''.

      Data WorkDir Type String Value ''.

      Data WinInc Type String Value ''.

      Data FileName Type String Value ''.

      Data ProcID Type i Value 0.

      Data rc Type i.

 

    "-Macros------------------------------------------------------------

      Define _.

        Concatenate Buffer &1 CrLf Into Buffer.

      End-Of-Definition.

 

      Define Flush.

        Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1.

      End-Of-Definition.

 

    "-Main--------------------------------------------------------------

      Create Object oFBSL 'FbslX'.

      If sy-subrc <> 0 Or  oFBSL-Handle = 0 Or oFBSL-Type <> 'OLE2'.

        Call Function 'ZFBSL_DLL'.

        Create Object oFBSL 'FbslX'.

      EndIf.

 

      If sy-subrc = 0 And oFBSL-Handle > 0 And oFBSL-Type = 'OLE2'.

 

        Call Method Of oFBSL 'About'.

 

        Call Method cl_gui_frontend_services=>get_sapgui_workdir

          Changing SAPWORKDIR = WorkDir Exceptions Others = 1.

 

        Call Method Of oFBSL 'ExtractFbslExe'.

 

"-FBSL script begin-----------------------------------------------------

_ 'Dim MaxIter = 50'.

_ 'Dim XRes As Integer'.

_ 'Dim YRes As Integer'.

_ 'Dim colors[MaxIter] As Integer'.

 

_ 'FBSLSETTEXT(Me, "DynC Mandelbrot Benchmark")'.

_ 'RESIZE(Me, 0, 0, 400, 400)'.

_ 'SHOW(Me)'.

 

_ 'FillColorTable()'.

_ 'FBSL.GETCLIENTRECT(ME, 0, 0, XRes, YRes)'.

 

_ 'Dim hdc = GetDC(ME)'.

_ 'Dim t = GetTickCount()'.

 

_ 'GenMandelbrot(-2.1, -1.25, 0.6, 1.25, XRes, YRes, MaxIter, hDC, _'.

_ '  @colors[0])'.

 

_ 'MSGBOX(, GetTickCount() - t & " ticks", "FBSL",)'.

_ 'ReleaseDC(ME, hdc)'.

 

  "-Dynamic C routine begin---------------------------------------------

_ 'DynC GenMandelbrot(!!xMn, !!yMn, !!xMx, !!yMx, %xr, %yr, %mitrs, _'.

_ '  %dc, %clr)'.

 

    "-ANSI C begin------------------------------------------------------

    "-

    "- You can store this code block in an include

    "-

    "-------------------------------------------------------------------

 

_ '  void __attribute__((stdcall)) SetPixel(int, int, int, int);'.

 

_ '  int Iterate(double cx, double cy, int MaxIter)'.

_ '  {'.

_ '    int iters = 0;'.

_ '    double X = cx, Y = cy, X2 = X * X, Y2 = Y * Y;'.

_ '    double temp;'.

 

_ '    while (iters++ < MaxIter && X2 + Y2 < 4) {'.

_ '      temp = cx + X2 - Y2;'.

_ '      Y = cy + 2 * X * Y;'.

_ '      Y2 = Y * Y;'.

_ '      X = temp;'.

_ '      X2 = X * X;'.

_ '    }'.

 

_ '    return iters;'.

_ '  }'.

 

_ '  void main(double xMn, double yMn, double xMx, double yMx, '.

_ '    int XRes, int YRes, int MaxIter, int hDC, int* colors[])'.

_ '  {'.

_ '    int iX, iY, iters;'.

_ '    double cx, cy;'.

_ '    double dx = (xMx - xMn) / (XRes - 1);'.

_ '    double dy = (yMx - yMn) / (YRes - 1);'.

 

_ '    for (iY = 0; iY < YRes; iY++) {'.

_ '      cy = yMn + iY * dy;'.

_ '      for (iX = 0; iX < XRes; iX++) {'.

_ '        cx = xMn + iX * dx;'.

_ '        iters = Iterate(cx, cy, MaxIter);'.

_ '        if (iters == MaxIter)'.

_ '          SetPixel(hDC, iX, iY, 0);'.

_ '        else'.

_ '          SetPixel(hDC, iX, iY, (int)colors[iters]);'.

_ '      }'.

_ '    }'.

 

_ '  }'.

 

    "-ANSI C end--------------------------------------------------------

 

_ 'End DynC'.

  "-Dynamic C routine end-----------------------------------------------

 

_ 'SUB FillColorTable()'.

_ '  DIM r, g, b'.

_ '  DIM rd, gd, bd'.

_ '  DIM rr, gg, bb'.

_ '  DIM i, j, wid'.

 

_ '  DIM clr[3]'.

_ '  clr[1] = RGB(0, 255, 0)'.

_ '  clr[2] = RGB(255, 255, 0)'.

_ '  clr[3] = RGB(255, 0, 0)'.

 

_ '  wid = MaxIter / 3'.

 

_ '  FOR j = 0 TO 2'.

_ '    toRGB(clr[j], r, g, b)'.

_ '    toRGB(clr[j + 1], rr, gg, bb)'.

_ '    rd = (rr - r) / (wid + 1)'.

_ '    gd = (gg - g) / (wid + 1)'.

_ '    bd = (bb - b) / (wid + 1)'.

_ '    FOR i = 0 TO wid'.

_ '      colors[j * wid + i] = RGB(r, g, b)'.

_ '      r = r + rd'.

_ '      g = g + gd'.

_ '      b = b + bd'.

_ '    NEXT'.

_ '  NEXT'.

_ 'END SUB'.

 

_ 'SUB toRGB(c, r, g, b)'.

_ '  r = c BAND &HFF'.

_ '  g = (c BAND &HFF00) / &H100'.

_ '  b = (c BAND &HFF0000) / &H10000'.

_ 'END SUB'.

"-FBSL script end-------------------------------------------------------

 

        Concatenate WorkDir '\' FbslFileName Into FileName.

        Call Method Of oFBSL 'WriteFile' Exporting #1 = FileName

          #2 = Buffer.

        Flush.

 

        Call Method Of oFBSL 'Shell' = ProcID Exporting

          #1 = 'Fbsl.exe' #2 = FbslFileName #3 = SW_SHOWNORMAL #4 = 1.

        Flush.

 

        Call Method Of oFBSL 'DeleteFile' Exporting #1 = FileName.

        Call Method Of oFBSL 'DeleteFile' Exporting #1 = 'Fbsl.exe'.

 

        Free Object oFBSL.

      EndIf.

 

"-End-------------------------------------------------------------------

 

zCMandelbrot.abap.jpg

 

You can store your C code in an include file and on this way you have an own C style code block inside your ABAP code.

 

In the message box you see the count of ticks (484) to generate the mandelbrot graphic. If you use the FBSL program, you need more ticks (2752) - look here.

 

Also you can use x86 assembler code. FBSL offers also an assembler layer. You can find FBSL here.

 

Have fun with your polyglot ABAP programs.

 

Cheers

Stefan

Program to extract any ALV in background to Excel

$
0
0

The standard behavior of ECC when running a ALV report in background of sending the output to spool, which of course can be converted to a html table or plain text file, is slightly frustrating. What most end user would like is the results in a spread sheet. Of course many solutions are possible but the approach I most recently took was to develop a ALV scheduler program by which I mean a program that will run any other program that outputs an ALV and save the ALV contents to an excel readable format. This new program then either saves this content to the server or emails it to a specified address. As the program is quiet versatile, being able to extract any ALV, I thought I could share it as it may be of use to others.

 

The file format I have used is the xml for excel format and the reason for this choice was the easy integration of this format using the class CL_SALV_EXPORT_DB_STORAGE. Although, xml may not be the first format the springs to mind when you think spreadsheet I found that most users don't really care as long as the file open with excel and this is what will happen with the xml excel file due to the processing instructions given you have a fairly standard windows setup with office. In the future I would like to add the option to save the output to xlsx using the really nice looking set of classes from abap2xlsx - ABAP Development - SCN Wiki but I'm not sure when it will be finished.

 

Anyway, for anyone whose interested the code is attached as three text files. One for the main program, one for the top include and one for the forms. I had also wanted to attach a Nugget file generated using SAPlink but I'm getting an error that they content type is not permitted.

 

So here's an example of how it works. In this example, I want to run the same program ZSP_BOREPORT twice but with different variants. So I enter my program name twice in the first select options

 

Image.png

Then in the second select options we enter the variants with which we want each run of the program to be executed

Image.png

Then on the rest of the selection screen we specify that we want the output of the different ALVs saved as sheets of one file rather than separate files and also that we want the sheets named after the variants. We also give a name to our file. Finally in the lowest box we specify that we want to save to the server rather than email out the results and we specify the path where we would like the file saved.

Image.png

Then once we execute we have a file that looks like this:Image.png

Of course the point of this program is not to run it in foreground but to run it in the background. This does add another level of abstraction or complexity as we have to schedule this ALV background program to run other program to extract their data in the background. However, I have found that the slight increase in complexity is more than compensated for by the user friendly format the data comes out in.

 

That's about everything. I hope it is of use to someone.

Renaming With Suffix - One of the unsung heros...

$
0
0
So what is "RENAMING WITH SUFFIX" ?
It is an addition for INCLUDE :
INCLUDE { {TYPE struc_type} | {STRUCTURE struc} }
        [AS name [RENAMING WITH SUFFIX suffix]].
So why am I such an admirer of this addition ? because it is a building block easily overlooked that a got a lot of potential .
usage scenarios:
Isolation of program changes
We are maintaining a very old ALV report program (Not ours !!! we were not born when it was written....) and we need to add new fields to the report.
So we add the new fields to the structure just to find out that the same fields name were was used orwe simply want to isolate our changes to reduce the chance of breaking something...
The program is complex and we do not want to start analyzing it (Time !!!) .

RWS (Renaming With Suffix....) for the rescue !!!

 

Note the use of the qualifier MODS_1 for addressing.

*----------------------------------------------------------------------*
FORM test_6_1 .

*----------------------------------------------------------------------*
  TYPES: BEGIN OF tp_mods_1 .  TYPES: field_01 TYPE string ,         field_02 TYPE string ,         field_03 TYPE string .  TYPES: END OF tp_mods_1 .
*----------------------------------------------------------------------*  TYPES: BEGIN OF tp_work_1 .  TYPES: field_02 TYPE string .  TYPES: END OF tp_work_1 .
*----------------------------------------------------------------------*
* The report structure type  TYPES: BEGIN OF tp_report .

* Those are the existing fields .
  TYPES: field_01 TYPE string ,         field_02 TYPE string ,         field_03 TYPE string ,
*        Long list of fields         field_99 TYPE string .

* Those are our new fields .
          INCLUDE TYPE tp_mods_1 AS mods_1 RENAMING WITH SUFFIX _mods_1 .  TYPES: END OF tp_report.  DATA: st_report TYPE tp_report .

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

  st_report-field_01 = 'This is st_report-field_01 ' .  DATA: st_work_1 TYPE tp_work_1 .  st_work_1-field_02 = 'I am from st_work_1-field_02' .  DATA: st_mods_1 TYPE tp_mods_1 .

* Here we can limit the target area using "-mods_1"
  MOVE-CORRESPONDING st_work_1 TO st_report-mods_1 .

* Access individuals fields
  st_report-mods_1-field_01 = 'This is st_report-mods_1-field_01 ' .  st_report-field_03_mods_1 = 'This is st_report-mods_1-field_03 aka field_03_mods_1 ' .

* Examine st_report
    BREAK-POINT .

ENDFORM .                                                   "test_6_1
*----------------------------------------------------------------------*
And this is what we have in  st_report:
capture_20131010_090634.png


Cross Tab (aka dynamic columns ) .

 

Another usage scenario where RWS shine is in the Cross Tab reports.

 

There are a lot of discussions about using cl_alv_table_create=>create_dynamic_table so I am not going to do that .

 

But what about those cases where the number of columns is not in the thousands ? do we really need create columns at run time ?

The reason I am saying that is because it simpler and cheaper to develop a program that use a fix number of columns .

 

Our mission:

 

A weekly report based on SFLIGHT and in this report for each week we need the total of PAYMENTSUM,SEATSOCC.

 

We need to cover a year . So it seems that we will have to create at least 53 * 2 = 106 fields .

What will happen if we also at some point want to add SEATSOCC_B and SEATSOCC_F for each week ? well this seems quite a lot...

 

Lets see how we can reduce the burden:

 

Program Y_R_EITAN_TEST_06_03 (Attached) will demonstrate it.

Our data setup looks like this:

*----------------------------------------------------------------------*
* For each week we want "Total of current bookings","Occupied seats in economy class"
TYPES: BEGIN OF tp_ent_xxx .
TYPES: paymentsum    TYPE sflight-paymentsum ,       seatsocc      TYPE sflight-seatsocc .
TYPES: END OF tp_ent_xxx .

TYPES: tp_sum_xxx TYPE tp_ent_xxx .
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
TYPES: BEGIN OF tp_vald_1 .

* Note the RENAMING WITH SUFFIX .

        INCLUDE TYPE tp_ent_xxx AS ent_001 RENAMING WITH SUFFIX _ent_001 .        INCLUDE TYPE tp_ent_xxx AS ent_002 RENAMING WITH SUFFIX _ent_002 .        INCLUDE TYPE tp_ent_xxx AS ent_003 RENAMING WITH SUFFIX _ent_003 .        INCLUDE TYPE tp_ent_xxx AS ent_004 RENAMING WITH SUFFIX _ent_004 .
Up to.....                INCLUDE TYPE tp_ent_xxx AS ent_052 RENAMING WITH SUFFIX _ent_052 .        INCLUDE TYPE tp_ent_xxx AS ent_053 RENAMING WITH SUFFIX _ent_053 .        INCLUDE TYPE tp_sum_xxx AS sum_xxx RENAMING WITH SUFFIX _sum_xxx .

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

This will generate our weekly sets.

 

If we need to add more fields for each week we only need to add them to type tp_ent_xxx .

The program analyze the data and will display only the active weeks .

This is done by using the set_technical method (The progam is using cl_salv_table).

 

In case of cl_gui_alv_grid we can use the field catalog (lvc_s_fcat-tech) .

 

This is the output from this program:

Clipboard03.jpg

Spain Modelo 340 - Interval OSS Note and Abap example

$
0
0

Hello,

 

For Spain, there is a standard transaction that allow you generate the monthly declaration called M340.

 

The standard transaction is S_E4A_94000356 - Report RFIDESM340

 

This transaction generates a report that is not totally complete, because the Interval columns are not populated, due to an absence of a counter dependent on the client business requirements.

 

to be able to populate the interval columns :

 

Step 1 : Implement OSS Note 1392825 - Modification of Exit LGL_RPT_EXIT_GET_ACC_INTERVAL.

 

Step 2 : Once Exit activated, you can start coding to populate the interval columns :

 

bellow the example used :

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

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

*&  Include           ZEXITM340

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

*types declaration

TYPES : BEGIN OF t_counter,

          belnr      LIKE tax_line_input-belnr,

          mwskz      LIKE tax_line_input-mwskz,

          fcount(3)  TYPE n,

          lcount(3)  TYPE n,

        END OF t_counter.

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

* data declaration

DATA lw_counter(3) TYPE n.

DATA lt_bseg       TYPE STANDARD TABLE OF bseg.

DATA ls_bseg       TYPE bseg.

DATA lw_belnr      LIKE tax_line_input-belnr.

DATA lt_counter     TYPE TABLE OF t_counter.

DATA ls_counter      TYPE t_counter.

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

 

IMPORT lt_counter FROM MEMORY ID 'ZEXITM340_Zcounter'.

 

lw_counter  =  1.

 

SELECT * FROM bseg INTO TABLE lt_bseg WHERE belnr = tax_line_input-belnr

                                        AND hkont = tax_line_input-hkont

                                        AND gjahr = tax_line_input-gjahr.

 

 

SORT lt_counter BY belnr lcount DESCENDING.

 

 

 

  READ TABLE lt_counter INTO ls_counter WITH KEY belnr = tax_line_input-belnr

                                             mwskz = tax_line_input-mwskz.

 

  IF sy-subrc = 0.

 

    CONCATENATE tax_line_input-belnr ls_counter-fcount INTO acc_int_first .

    CONCATENATE tax_line_input-belnr ls_counter-lcount INTO acc_int_last .

 

  ELSE.

 

    READ TABLE lt_counter INTO ls_counter WITH KEY belnr = tax_line_input-belnr.

 

    IF sy-subrc = 0 .

      MOVE  ls_counter-lcount TO lw_counter.

      ADD 1 TO lw_counter.

    ENDIF.

 

    CONCATENATE tax_line_input-belnr lw_counter INTO acc_int_first .

    SUBTRACT 1 FROM lw_counter.

 

    LOOP AT lt_bseg INTO ls_bseg

    WHERE mwskz  = tax_line_input-mwskz

      AND hkont BETWEEN 0070000000 AND 0070099999.

 

      lw_counter  =  lw_counter + 1.

 

    ENDLOOP.

 

 

    IF lw_counter = acc_int_first+10(3) .

      ADD 1 TO lw_counter.

    ENDIF.

 

* sometimes the lw_counter is 000 witch is due to bad selection of G/L Account in (TAX_LINE_INPUT = wa_tax_item)

* so the objectif is to correct this error hard coded way

    if lw_counter = 000.

      add 2 to lw_counter.

    endif.

 

 

    CONCATENATE tax_line_input-belnr lw_counter INTO acc_int_last .

 

    ls_counter-belnr   = tax_line_input-belnr.

    ls_counter-mwskz   = tax_line_input-mwskz.

    ls_counter-fcount  =  acc_int_first .

    ls_counter-lcount  =  acc_int_last .

 

    APPEND ls_counter TO lt_counter.

 

  ENDIF.

 

 

 

*export global data for counter

EXPORT lt_counter  TO MEMORY ID 'ZEXITM340_Zcounter'.

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

 

Of course you need to adapt the Exit depending on the client business requirement,

 

there is some new OSS notes regarding the modelo 340 for Spain, so do not hesitate to check and update your modelo

Enjoy!


Recently Featured Content in ABAP Development

$
0
0

ABAP Language News for Release 7.40 SP05

http://scn.sap.com/profile-image-display.jspa?imageID=26426&size=72SP05 for AS ABAP 7.40 comes with a new kernel release 741 and a new kernel release means new ABAP language features. Read this blog by Horst Keller covering the most important ABAP language news.February 6, 2014

 

What is ANST and why aren't you using it?

http://scn.sap.com/profile-image-display.jspa?imageID=10179&size=72Do you already know ANST, the Automated Notes Search Tool? This powerful application searches SAP notes for a specific problem based on the issue in your system. For more information, read this blog by Kristen Scheffler.January 9, 2014

 

SQL Monitor Unleashed

Have you heard about the SQL Monitor already? It can be used to detect custom code which can be optimized (in the context of the migration to SAP HANA, but also independent of that). If you like to learn more, read Johannes Marbach's blog series. You find the first blog here.November 18, 2013

 

Considerations for Custom ABAP Code During a Migration to SAP HANA

Considering a migration of your custom code to an AS ABAP 7.4 on SAP HANA system? Then you should read this best practice guide by Eric Westenberger containing important considerations and recommendations.September 27, 2013

 

ABAP language news for SAP NetWeaver 7.4

Don't miss this comprehensive blog series by Horst Keller describing the latest enhancements of the ABAP programming language for the SAP NetWeaver Application Server ABAP 7.4 release.July 23, 2013

 

Now Available! SAP NetWeaver AS ABAP 7.4

SAP NetWeaver AS ABAP 7.4 provides non-disruptive innovations and enhancements for the proven and reliable ABAP technology and is optimized for SAP HANA, Cloud, and Mobile. Learn about the most significant values and capabilities of the SAP NetWeaver AS ABAP 7.4.

 

Learn more about NetWeaver 7.4 in blogs by Bjoern Goerke and Karl Kessler:

SAP NetWeaver 7.4 Made Generally Available (GA)

New landing page published for SAP NetWeaver 7.4

 

Explore the ABAP Development on SAP HANA step by step using ABAP for SAP HANA Reference Scenario Open Items Analytics which is an integral part of the SAP NetWeaver AS ABAP 7.4. May 13, 2013

 

ABAP Development Tools 2.7 are generally available!

http://scn.sap.com/profile-image-display.jspa?imageID=6190&size=72Testdrive the latest version of SAP's ABAP IDE on Eclipse and get familiar with its new features and enhancements. This article by Christopher Kaestner describes the highlights of the ABAP development tools 2.7 and where to download them.May 12, 2013

 

Performance Guidelines for ABAP Development on the SAP HANA Database

If you’re an experienced ABAP developer, you’re probably familiar with the classic performance guidelines for using Open SQL. This begs the question of what changes are there to the guidelines in the context of SAP HANA. Eric Westenberger tackles that question.  April 10, 2013

 

Experience the Magic: How to Setup Your Own ABAP on HANA in the Cloud

http://scn.sap.com/profile-image-display.jspa?imageID=12354&size=72Are you an ABAP developer who can’t wait to explore the intricacies of ABAP on HANA coding? Do you want to set up a sandbox environment where you can try out things such as consuming HANA Calculation Views or Stored Procedures from ABAP programs, and learn how to accelerate your ABAP applications with HANA or build entirely new ones? Then SAP Mentor Thorsten Franz wrote this for you. April 10, 2013

 

ABAP in Eclipse: Why Eclipse wins?

http://scn.sap.com/profile-image-display.jspa?imageID=17269&size=72 What makes working with ABAP in Eclipse more efficient as in SE80? In this blog, Adam Krawczyk shares his practical experience with ABAP Development Tools giving handy tips and advices for optimal usage.April 11, 2013

 

ABAP Code Modularization: Lesson Learned

http://scn.sap.com/profile-image-display.jspa?imageID=3669&size=72It can’t be all Objects all the time! In this blog, Otto Gold shares tips and best practices on how to structure program code depending on the situation. Mine through the comments section and you’ll find more nuggets of wisdom. Mr. Gold provides more nuggets in “My "light" tricks for building more "robust" ABAP code.”March 22, 2013

 

How to Create a Watch Point for a Field Symbol in the ABAP Debugger

You can’t create a watch point for a field symbol. You'll get an error. Try telling that to Brian O'Neill, who said, “Even though I received an error, I do not like being told what I can't do in SAP, so I decided to find a way!” March 18, 2013

 

ABAP for SAP HANA Fitness Contest at DSAG Technology Days

http://scn.sap.com/profile-image-display.jspa?imageID=3662&size=72SAP Mentor Tobias Trapp writes about the ABAP for SAP HANA Fitness Contest at DSAG Technology Days. There 20 customers and partners had the chance to get early insights into what ABAP development on SAP HANA as primary persistence means. March 4, 2013

 

 


SAP TechEd Live Interviews for ABAP Developers

 

Get more interviews and lecture sessions from SAP TechEd Online. January 8, 2012

 

Optimizing ABAP for SAP HANA: SAP's 3-Step Approach

In this SAPinsider article, you'll learn SAP's three-step approach to optimize SAP NetWeaver Application Server (SAP NetWeaver AS) ABAP for the SAP HANA database. December 26, 2012


ABAP Development Tools: Now you can debug ABAP applications in Eclipse

http://scn.sap.com/profile-image-display.jspa?imageID=6190&size=72Want to debug your ABAP applications with native Eclipse debugger directly within the ABAP Development Tools (ADT) for Eclipse? Now it's possible since the availability of the new SAP Kernel 7.21 in combination with SAP Basis 7.31 SP4 (prerequisite for using ADT). Learn the capabilities of the new ABAP debugger in Eclipse also by watching the embedded video. December 3, 2012

 


SAP Insider: Turbocharge Your ABAP Development with Innovation from Eclipse

https://scn.sap.com/profile-image-display.jspa?imageID=2207&size=72With SAP NetWeaver 7.31, support package stack 4, SAP introduces ABAP development tools for SAP NetWeaver, also known as "ABAP in Eclipse," which brings Eclipse capabilities to ABAP Workbench (SE80) functionality. In this SAP Insider article, you'll learn more about ABAP in Eclipse and how it moves ABAP, which is ripe for productivity and usability improvements, into a complementary alignment with SAP's other Eclipse-based development environments. November 26, 2012

 

Crossing the Great Divide - Procedural vs. OO ABAP Programming

http://scn.sap.com/profile-image-display.jspa?imageID=4295&size=72Indulge in this blog by Paul Hardy from Hanson Australia Pty Ltd, as he takes us through his journey from the “old school” (he started procedural programming at age 14) to modern programming techniques. November 6, 2012

 

 

A Call to Arms for ABAP Developers

http://scn.sap.com/profile-image-display.jspa?imageID=2427&size=72 SAP Mentor Graham Robinson shares his concerns for those who have not kept in touch with contemporary development trends including ABAP skills. Read his “call to arms.” October 26, 2012

 

 

 

ABAP Development Tools Tutorials - Learn how to use ABAP in Eclipse

Want to learn fast all new features and capabilities of the ABAP in Eclipse IDE? Just step through the short ABAP Development Tools video tutorials online.October 16, 2012


ABAP Technology @ SAP TechEd 2012

Are you interested in the latest ABAP technology news and visiting one of the upcoming SAP TechEd 2012 events? This blog post gives a brief overview of sessions that might be of interest for you. September 25, 2012


ABAP Test Cockpit – SAP’s new quality assurance tool

Bugs in your custom ABAP code can be quite expensive when they impact critical business processes. Thus, SAP invested in the ABAP Test Cockpit (ATC), SAP’s new quality assurance tool for ABAP. Read this document to learn more about ATC. September 21, 2012


Free Trial on SCN for ABAP in Eclipse

Want to check out ABAP in Eclipse? Simply download the SCN trial version following the ABAP Development Tools for SAP NetWeaver - Trial Version document orvisit the new space focusing on the Eclipse-based ABAP Development Tools for SAP NetWeaver. July 5, 2012


SAP NetWeaver AS ABAP for HANA

How does ABAP help to leverage the benefits of in-memory database technology? This documentdescribes SAP's vision, strategy, development, and commitment to enable ABAP for SAP HANA. Also available in German language.June 25, 2012

 

ABAP in Eclipse is Here!

ABAP in Eclipse was shipped on 25 June with SAP NetWeaver AS ABAP 7.03/7.31 SP4. Visit the new space focusing on the Eclipse-based ABAP Development Tools for SAP NetWeaver, or “ABAP in Eclipse.” Check out Get Started with ABAP Development Tools for SAP NetWeaver, Working with ABAP Development Tools, and Download and Installation Instructions (SMP login required). June 26, 2012

 

"Light" Tricks for Building More "Robust" ABAP Code

http://scn.sap.com/profile-image-display.jspa?imageID=3669&size=72 SAP Mentor Otto Gold shares some thoughts on ABAP coding and general development, and sparks another robust discussion following his blog. Otto offers up more useful tricks in another recent blog, All you need to know about HR-PD Qualifications from the development perspective. June 12, 2012

 

 

Modernizing ABAP Development

Questions about code modernization and skills development tend to leave a big footprint on SCN. In this blog, Brian O'Neill of IGT asks how and whether to modernize. June 12, 2012

 

Customer Feedback on the Pilot Version of the ABAP Development Tools for SAP NetWeaver

http://scn.sap.com/profile-image-display.jspa?imageID=4972&size=72Also known as "ABAP in Eclipse," ABAP Development Tools for SAP NetWeaver were part of a customer engagement initiative to evaluate the pilot version. Olga Dolinskaja summarizes the results. May 3, 2012

 

 

 

Developer's Journal: ABAP/HANA Connectivity via Secondary Database Connection

http://scn.sap.com/profile-image-display.jspa?imageID=2203&size=72

Interested in how to access HANA from your ABAP systems? In his edition of the HANA Developer's Journal Thomas Jung expains how much can be done today when HANA runs as a secondary database for your current ABAP based systems and what development options within the ABAP environment support this  scenario. April 23, 2012


 

 

The quality of an answer depends significantly on the quality of the question (or: how to ask good questions)

In his post Hermann Gahmgives some useful hints how to ask 'good' questions and especially correct questions regarding ABAP code in order to get an answer of a good quality. April 23, 2012

 

ABAP Objects: Performance Analysis (SAT) with ABAP Unit

Posted by Bjorn-Henrik Zink. February 2, 2012

 

How to Do ABAP Nugget Based Code Migration

SAPlink is a project that aims to make it easier to share ABAP developments between programmers. It provides the ability to easily distribute and package custom objects. This article covers ABAP basis versions compatible with SAPlink and how to install the latest version of SAPlink. January 26, 2012

 

ABAP Keyword Documentation 7.03/7.31

The ABAP Keyword Documentation for Release 7.31 aka 7.03 is online. January 14, 2012

 

Coding and Performance Tips for New ABAP Programmers

In this blog, SAP Technology Analyst, Nabheet Madan, offers tips for new ABAP programmers who have just developed a few objects. Nabheet looks at fundamentals including documentation and reusable code, naming conventions, maintainability and performance optimization. January 3, 2012

 

2011

 

ABAP Trilemma

The ABAP development triangle is a model that describes the trilemma of ABAP development. In this blog, Elvez describes how the ABAP development triangle - performance, security and design - can be used as an agreement between developers on how to prioritize development efforts. December 13, 2011

How to - Add Custom XML Parts to Microsoft Word using ABAP

$
0
0

This document explains how to:

 

Add Custom XML Parts to Word using ABAP

 

    1. Prepare XML data

METHOD prepare_customxml.
*    Exporting  EV_CUSTOMXML4DOC  TYPE XSTRING
*    Exception  XSLT_ERROR
  CONSTANTS:  lc_encode        TYPE abap_encod VALUE 'UTF-8'.
  DATA:
        lv_customxml4doc          TYPE string,
        l_convout                          TYPE REF TO cl_abap_conv_out_ce,
        lv_len                                TYPE i.
  l_convout = cl_abap_conv_out_ce=>create( encoding = lc_encode ).
  lv_customxml4doc = '<xmlDOC value="This is an example of valid xml" />'. "You can add a valid xml here
  l_convout->convert(
      EXPORTING
              data  = lv_customxml4doc
      IMPORTING
              buffer = ev_customxml4doc
              len    = lv_len ).

ENDMETHOD.

    2. Get the Word template

              The template can be uploaded to the MIME repository and can be read from there.
METHOD get_doc_template.
*    Exporting EV_DOC TYPE XSTRING
  DATA:
  lo_mr_api                  TYPE REF TO if_mr_api.
  lo_mr_api = cl_mime_repository_api=>get_api( ).
  lo_mr_api->get(
        EXPORTING
              i_url    = doc_template_url          "Give the template url in MIME repository here
        IMPORTING
              e_content = ev_doc
        EXCEPTIONS
              OTHERS    = 1
  ).

ENDMETHOD.

    3. Add Custom XML to Word template

METHOD add_customxml2doc.
*    Importing      IV_DOC                      TYPE XSTRING
*    Importing      IV_CUSTOMXML        TYPE XSTRING
*    Exporting      EV_DOC                    TYPE XSTRING   
*    Exception      XSLT_ERROR
  DATA:
    doc                            TYPE REF TO cl_docx_document,
    documentpart            TYPE REF TO cl_docx_maindocumentpart,
    l_packagecontent        TYPE string,
    customxmlpartcoll      TYPE REF TO cl_openxml_partcollection,
    customxmlpart            TYPE REF TO cl_oxml_customxmlpart,
    customxmlpropspart  TYPE REF TOTO cl_oxml_customxmlpropspart,
    propertyxml                TYPE xstring,
    preguid                        TYPE string,
    guid                            TYPE string.
  TRY.
    doc = cl_docx_document=>load_document( iv_data = iv_doc ).
      l_packagecontent = doc->get_content_type( ).
* get the maindocument part
      documentpart = doc->get_maindocumentpart( ).
* get collection of customXML parts
      customxmlpartcoll = documentpart->get_customxmlparts( ).
* create a customXML part here
      customxmlpart = documentpart->add_customxmlpart( ).
* insert xml data
      customxmlpart->feed_data( iv_customxml  ).
* add customXML properties part
      customxmlpropspart = customxmlpart->add_customxmlpropspart( ).
* create GUID string
      preguid = cl_openxml_helper=>create_guid_string( ).
* enclose with {...} brackets
      CONCATENATE '{' preguid '}' INTO guid.
* create custom XML property content
      CALL TRANSFORMATION docx_create_custompropscontent
            PARAMETERS guid = guid
            SOURCE XML iv_customxml
            RESULT XML propertyxml.
* insert propertyxml
      customxmlpropspart->feed_data( propertyxml ).
      ev_doc = doc->get_package_data( ).
    CATCH cx_openxml_format.
    CATCH cx_openxml_not_allowed.
    CATCH cx_openxml_not_found.
    CATCH cx_transformation_error.
      RAISE xslt_error.
  ENDTRY.

ENDMETHOD.

    4. Integrate the above steps - XML, Word template, Custom XML

METHOD get_doc_download.
*      Exporting EV_XML_XSTRING_DOC      TYPE XSTRING
*      Exception ERROR_OCCURRED
  DATA:
              lv_customxml4doc      TYPE xstring,
              lv_doc_template          TYPE xstring.
  prepare_customxml(
    IMPORTING
      ev_customxml4doc = lv_customxml4doc
    EXCEPTIONS
      xslt_error          = 1
      OTHERS          = 2
                        ).
  IF sy-subrc = 1.
    RAISE error_occurred.
  ELSEIF sy-subrc = 2.
    RAISE error_occurred.
  ENDIF.
  get_doc_template(
    IMPORTING
      ev_doc          = lv_doc_template
                  ).

  add_customxml2doc(
    EXPORTING
      iv_doc                = lv_doc_template
      iv_customxml    = lv_customxml4doc
    IMPORTING
      ev_doc                = ev_xml_xstring_doc
    EXCEPTIONS
      xslt_error        = 1
      OTHERS        = 2
                    ).

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

ENDMETHOD.

 

 

 

Related Articles:

 

How to - Add Custom XML Parts to Microsoft Excel using ABAP

$
0
0

This document explains how to:

 

Add Custom XML Parts to Excel using ABAP

 

    1. Prepare XML data

METHOD prepare_customxml.
*    Exporting  EV_CUSTOMXML4XLS  TYPE XSTRING
*    Exception  XSLT_ERROR
  CONSTANTS:  lc_encode        TYPE abap_encod VALUE 'UTF-8'.
  DATA:
        lv_customxml4xls              TYPE string,
        l_convout                          TYPE REF TO cl_abap_conv_out_ce,
        lv_len                                TYPE i.
  l_convout = cl_abap_conv_out_ce=>create( encoding = lc_encode ).
  lv_customxml4xls = '<xmlXLS value="This is an example of valid xml" />'. "You can add a valid xml here
  l_convout->convert(
      EXPORTING
              data  = lv_customxml4xls
      IMPORTING
              buffer = ev_customxml4xls
              len    = lv_len ).

ENDMETHOD.

    2. Get the Excel template

              The template can be uploaded to the MIME repository and can be read from there.
METHOD get_xls_template.
*    Exporting EV_XLS TYPE XSTRING
  DATA:
  lo_mr_api                  TYPE REF TO if_mr_api.
  lo_mr_api = cl_mime_repository_api=>get_api( ).
  lo_mr_api->get(
        EXPORTING
              i_url    = xls_template_url          "Give the template url in MIME repository here
        IMPORTING
              e_content = ev_xls
        EXCEPTIONS
              OTHERS    = 1
  ).

ENDMETHOD.

    3. Add Custom XML to Excel template

METHOD add_customxml2xls.
*    Importing      IV_XLS                    TYPE XSTRING
*    Importing      IV_CUSTOMXML    TYPE XSTRING
*    Exporting      EV_XLS                    TYPE XSTRING   
*    Exception      XSLT_ERROR
  DATA:
    xls                              TYPE REF TO cl_xlsx_document,
    workbookpart            TYPE REF TO cl_xlsx_workbookpart,
    l_packagecontent        TYPE string,
    customxmlpartcoll      TYPE REF TO cl_openxml_partcollection,
    customxmlpart            TYPE REF TO cl_oxml_customxmlpart,
    customxmlpropspart  TYPE REF TOTO cl_oxml_customxmlpropspart,
    propertyxml                TYPE xstring,
    preguid                        TYPE string,
    guid                            TYPE string.
  TRY.
    xls = cl_xlsx_document=>load_document( iv_data = iv_xls ).
      l_packagecontent = xls->get_content_type( ).
* get the workbook part
      workbookpart = xls->get_workbookpart( ).
* get collection of customXML parts
      customxmlpartcoll = workbookpart->get_customxmlparts( ).
* create a customXML part here
      customxmlpart = workbookpart->add_customxmlpart( ).
* insert xml data
      customxmlpart->feed_data( iv_customxml  ).
* add customXML properties part
      customxmlpropspart = customxmlpart->add_customxmlpropspart( ).
* create GUID string
      preguid = cl_openxml_helper=>create_guid_string( ).
* enclose with {...} brackets
      CONCATENATE '{' preguid '}' INTO guid.
* create custom XML property content
      CALL TRANSFORMATION docx_create_custompropscontent
            PARAMETERS guid = guid
            SOURCE XML iv_customxml
            RESULT XML propertyxml.
* insert propertyxml
      customxmlpropspart->feed_data( propertyxml ).
      ev_xls = xls->get_package_data( ).
    CATCH cx_openxml_format.
    CATCH cx_openxml_not_allowed.
    CATCH cx_openxml_not_found.
    CATCH cx_transformation_error.
      RAISE xslt_error.
  ENDTRY.

ENDMETHOD.

    4. Integrate the above steps - XML, Excel template, Custom XML

METHOD get_xls_download.
*      Exporting EV_XML_XSTRING_XLS      TYPE XSTRING
*      Exception ERROR_OCCURRED
  DATA:
              lv_customxml4xls      TYPE xstring,
              lv_xls_template          TYPE xstring.
  prepare_customxml(
    IMPORTING
      ev_customxml4xls = lv_customxml4xls
    EXCEPTIONS
      xslt_error          = 1
      OTHERS          = 2
                        ).
  IF sy-subrc = 1.
    RAISE error_occurred.
  ELSEIF sy-subrc = 2.
    RAISE error_occurred.
  ENDIF.
  get_xls_template(
    IMPORTING
      ev_xls          = lv_xls_template
                  ).

  add_customxml2xls(
    EXPORTING
      iv_xls                = lv_xls_template
      iv_customxml    = lv_customxml4xls
    IMPORTING
      ev_xls                = ev_xml_xstring_xls
    EXCEPTIONS
      xslt_error        = 1
      OTHERS        = 2
                    ).

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

ENDMETHOD.

 

 

 

Related Articles:

 


How to - Add Custom XML Parts to Microsoft PowerPoint using ABAP

$
0
0

This document explains how to:

 

Add Custom XML Parts to PowerPoint using ABAP

 

    1. Prepare XML data

METHOD prepare_customxml.
*    Exporting  EV_CUSTOMXML4PPT  TYPE XSTRING
*    Exception  XSLT_ERROR
  CONSTANTS:  lc_encode        TYPE abap_encod VALUE 'UTF-8'.
  DATA:
        lv_customxml4ppt              TYPE string,
        l_convout                          TYPE REF TO cl_abap_conv_out_ce,
        lv_len                                TYPE i.
  l_convout = cl_abap_conv_out_ce=>create( encoding = lc_encode ).
  lv_customxml4ppt = '<xmlPPT value="This is an example of valid xml" />'. "You can add a valid xml here
  l_convout->convert(
      EXPORTING
              data  = lv_customxml4ppt
      IMPORTING
              buffer = ev_customxml4ppt
              len    = lv_len ).

ENDMETHOD.

    2. Get the PowerPoint template

              The template can be uploaded to the MIME repository and can be read from there.
METHOD get_ppt_template.
*    Exporting EV_PPT TYPE XSTRING
  DATA:
  lo_mr_api                  TYPE REF TO if_mr_api.
  lo_mr_api = cl_mime_repository_api=>get_api( ).
  lo_mr_api->get(
        EXPORTING
              i_url    = ppt_template_url          "Give the template url in MIME repository here
        IMPORTING
              e_content = ev_ppt
        EXCEPTIONS
              OTHERS    = 1
  ).

ENDMETHOD.

    3. Add Custom XML to PowerPoint template

METHOD add_customxml2ppt.
*    Importing      IV_PPT                    TYPE XSTRING
*    Importing      IV_CUSTOMXML    TYPE XSTRING
*    Exporting      EV_PPT                    TYPE XSTRING   
*    Exception      XSLT_ERROR
  DATA:
    ppt                              TYPE REF TO cl_pptx_document,
    presentationpart          TYPE REF TO cl_pptx_presentationpart,
    l_packagecontent        TYPE string,
    customxmlpartcoll      TYPE REF TO cl_openxml_partcollection,
    customxmlpart            TYPE REF TO cl_oxml_customxmlpart,
    customxmlpropspart  TYPE REF TOTO cl_oxml_customxmlpropspart,
    propertyxml                TYPE xstring,
    preguid                        TYPE string,
    guid                            TYPE string.
  TRY.
      ppt = cl_pptx_document=>load_document( iv_data = iv_ppt ).
      l_packagecontent = ppt->get_content_type( ).
* get the presentation part
      presentationpart = ppt->get_presentationpart( ).
* get collection of customXML parts
      customxmlpartcoll = presentationpart->get_customxmlparts( ).
* create a customXML part here
      customxmlpart = presentationpart->add_customxmlpart( ).
* insert xml data
      customxmlpart->feed_data( iv_customxml  ).
* add customXML properties part
      customxmlpropspart = customxmlpart->add_customxmlpropspart( ).
* create GUID string
      preguid = cl_openxml_helper=>create_guid_string( ).
* enclose with {...} brackets
      CONCATENATE '{' preguid '}' INTO guid.
* create custom XML property content
      CALL TRANSFORMATION docx_create_custompropscontent
            PARAMETERS guid = guid
            SOURCE XML iv_customxml
            RESULT XML propertyxml.
* insert propertyxml
      customxmlpropspart->feed_data( propertyxml ).
      ev_ppt = ppt->get_package_data( ).
    CATCH cx_openxml_format.
    CATCH cx_openxml_not_allowed.
    CATCH cx_openxml_not_found.
    CATCH cx_transformation_error.
      RAISE xslt_error.
  ENDTRY.

ENDMETHOD.

    4. Integrate the above steps - XML, PowerPoint template, Custom XML

METHOD get_ppt_download.
*      Exporting EV_XML_XSTRING_PPT      TYPE XSTRING
*      Exception ERROR_OCCURRED
  DATA:
              lv_customxml4ppt      TYPE xstring,
              lv_ppt_template          TYPE xstring.
  prepare_customxml(
    IMPORTING
      ev_customxml4ppt = lv_customxml4ppt
    EXCEPTIONS
      xslt_error          = 1
      OTHERS          = 2
                        ).
  IF sy-subrc = 1.
    RAISE error_occurred.
  ELSEIF sy-subrc = 2.
    RAISE error_occurred.
  ENDIF.
  get_ppt_template(
    IMPORTING
      ev_ppt          = lv_ppt_template
                  ).

  add_customxml2ppt(
    EXPORTING
      iv_ppt                = lv_ppt_template
      iv_customxml    = lv_customxml4ppt
    IMPORTING
      ev_ppt                = ev_xml_xstring_ppt
    EXCEPTIONS
      xslt_error        = 1
      OTHERS        = 2
                    ).

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

ENDMETHOD.

 

 

 

Related Articles:

 

Featured Content for ABAP Development

$
0
0

Become an ABAP in Eclipse Fan and earn the AIE Fan Badge

https://s3.amazonaws.com/bunchball_images/429cbb113e7341acacf696b4390e5431/abapineclipsefan75png1453dd77506.png Are you an ABAP developer, fascinated by the new IDE? Do you want to be a member of this new generation of ABAP developers? Read this blog by Thomas Fiedler describing how to become an ABAP in Eclipse fan.April 8, 2014

 

JavaScript for ABAP Developers

For those ABAPers who also want to engage in JavaScript development and plunge into the low-level details, Chris Whealy revamped and released some interesting training slides.March 17, 2014

 

SAP NetWeaver AS Add-On for Code Vulnerability Analysis

http://scn.sap.com/profile-image-display.jspa?imageID=21719&size=72Have you ever heard about the Code Vulnerability Analyzer? This new SAP NetWeaver Add-On allows to search for potential security vulnerabilities in ABAP source code. For more information, read the SAP Insider's article Start Your ABAP Applications on Solid Ground written by Patrick Hildenbrand.February 25, 2014

 

Free Developer Edition: AS ABAP incl. BW on SAP HANA

Do you want to explore the latest features of SAP Business Warehouse, try out ABAP development on SAP HANA or the SAP HANA interactive education? Now we offer a new developer edition of AS ABAP incl. BW 7.4 SP5 on SAP HANA SP7 for our developer community.February 18, 2014

 

Getting Started with AS ABAP 7.4 SP5 incl. BW on SAP HANA SP7 [Developer Edition]

$
0
0

This guide describes how to set up and run the developer edition of Application Server ABAP 7.4 SP5 on SAP HANA SP7, which is provided as virtual appliance by the SAP Cloud Appliance Library.

View this Document

TEN COMMANDMENTS IN ABAP

$
0
0


1.    Thou shall choose the most efficient statement to access the database and minimize the data baggage that is brought back.

          Avoid any en route operations as much as possible.

 

The key here is

    • Reduce database load
    • Reduce network load
    • Only read necessary data
    • No multiple reads
    • Application of buffering techniques
    • Minimize search effort for the database using indexes.
    • Use bundling techniques to fill data packages
    • Favor mass accesses.

 

     Refer this link for the guidelines in database operations which were pulled together from the vast amount of resources available on net and SAP documentation.      Efficient Database Operations - SAP Developer Challenge - SCN Wiki

      

2.  Thou shall make proficient use of Logical Database

 

  • SAP provides many logical databases for reading records from the database. Logical databases are ABAP programs that decouple Open SQL statements from application programs and have been optimized by SAP for the best database performance. So when reading data from database involves many tables, use logical database.

 

  • Be sure to choose the most suitable logical database. Logical database has a hierarchical structure. So if you want data from a node at the lowest level, avoid using logical database. Use select statement instead or another data where this node is at a higher level.

  

  • If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database

 

  • When using the GET event keyword to retrieve records via a logical database, selection can be restricted by using the CHECK statement (using either CHECK select-option(s) or CHECK condition).

    In this case, a CHECK statement that returns a negative result terminates the processing of GET events for subordinate database tables and the associated data is not read. For efficiency reasons, always perform the CHECK at the highest possible level of the database hierarchy.

  

  • When you are creating a custom logical database, bear in mind that the use of very large tables will degrade the performance of a logical database. Also, remember that some tables in SAP are very complex, so they will be problematic in any user-defined logical database.

 

3.   When creating database tables, thou shall not leave it half done.

 

   Provide the correct technical settings to enable faster accesses to the tables in the

 

  • Specifying the right data class to the table allocates the table to the most appropriate physical file on the disk on the database server. Tables with similar characteristics, like, those that can grow quickly are all grouped together in that part of disk (table space for Oracle and DB space for Informix) where there is a lot of free space.
    • Master data table can be specified under APPL0 as they are not updated very often and grows slowly – like vendor master
    • Transaction data can be specified APPL1 as they are updated very quickly and will grow very quickly. Like order placedon a vendor.
    • APPL2 data class is mainly assigned for configuration tables like text tables and other check tables whose contents are determined at the size of creation itself and do not change much after that.

  

  • It is also important that you specify the right size category. Here the rule is, 'It is okay to provide an overestimated size of database table but never underestimate.' Cause if you specify a size that is underestimated and the table grows larger than the space initially associated to it, then reorganization is required when the next space (each allocated space is called extent) is allocated. This will tremendously reduce the efficiency of the tables.

 

  • Try to create secondary indexes when there will be frequent accesses on the table for a particular set of fields in where clause. These fields should be mentioned in the where clause of the select statement in the same order as specified in the index. However, don’t create index if it will be rarely used, it will create an unnecessary burden. Also don’t create indexes using the same fields as that of an existing index.

  

  • Whenever you create an index, make sure you include the ‘mandt’ field also in the index if it is a client dependent table.

 

  • It would be better to enable buffering if there is requirement to read database table frequently with no update operations. Buffering would be even more beneficial and reliable if there is only one application server connected to the database server. If buffering is enabled and there is more than one application server, then you will need to use the select statement with the clause bypassing buffer if you require the most updated data in the database.

  

You can considerably reduce the time required to access data by buffering it in the application server table buffer. Reading a single entry from table T001 can take between 8 and 600 milliseconds, while reading it from the table buffer takes 0.2 - 1 milliseconds.

 

  • Enable log data changes only for table containing very critical data for which every change has to be tracked, since this slows down each update in the table.

 

4.  Thou shall not be naïve when working with internal tables.

 

Array Operations

 

ABAP documentation generally describes this type of processing as block operation. When internal tables are filled from database tables, the INTO TABLE itab keyword causes the SELECT statement to insert the data records en bloc to the internal tables

 

An array interface is also available for filling internal tables from other internal tables. The corresponding ABAP statements are:

 

APPEND LINES OF itab1 TO itab2.

 

INSERT LINES OF itab1 INTO TABLE itab2.

 

  • Prefer array operations on internal tables to single record operations (next section) wherever possible because the kernel can process administrative work (for example, memory allocation) more efficiently.

  

For more SAP recommended guidelines on intelligent operations with internal tables, refer this link

Efficient Database and Internal Table Operations - SAP Developer Challenge - SCN Wiki

 

5.  Thou shall not try to reinvent the wheel.

 

Use already existing function modules and operations rather than creating your own logic.

 

  • Many times the function modules exist for accessing the data. Instead of reading directly from the table,use these function modules. If same kind of information is read in various transactions, there is a high probability that a function module exist for reading that information. The run-time analysis or debug can give more information.

 

  • Function modules exist for frequently used actions. You can search for the function module based on some keyword.  For example, if you were searching for a function module for pricing, search the function module giving *pricing*.  If you are searching for conversion exits for formatting data, give *conversion*exit* or for popup functions, try *popup*.

  

  • For string operations, use the various available string operations, rather than implementing your logic for the same. Example:

To find out the length of a field use the string length function.   
FLDLEN = STRLEN (FLD).

 

  • Similarly use the internal table functions available rather than using your own logic for various table operations. Example:

  

DESCRIBE TABLE ITAB LINES CNTLNS. 

 

Is more efficient than
LOOP AT ITAB.
CNTLNS = CNTLNS + 1.
ENDLOOP.

 

 

6.  Thou shall reflect and proceed wisely when using conditional loops

 

  • Use the most probable cases first.

 

  • When coding IF tests, nest the testing conditions so that the outer conditions are those which are most frequently true. This will ensure minimal code execution.

  

  • Similarly, for logical expressions with ‘AND’, place the most likely false first. For the ‘OR’ operator, place the most likely true first.

 

  • For Case statement, place the most likely case first.

  

  • If and Case structures – The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient.

 

  • WHILE vs DO – While is faster to execute than do statements.

  

  • Make use of the statements CHECK, EXIT, REJECT, STOP & CONTINUE in loops. This will suspend processing and/or skip remaining unnecessary processing for improved performance. And try to put them as much above in the conditional block as possible.

 

7.  Thou shall give thoughtful judgment on Modularization of code – subroutines, function modules and methods

 

  • Whenever values need to be passed in a subroutine, have type declarations assigned to the formal parameters. If no specific type declaration is possible then use TYPE ANY. This improves the performance.

  

  • Determine the need to perform  subroutine before you call it.

 

  • Take into account initialization time for local variables

  

  • Use LOCAL rather than TABLES statement in subroutines

 

  • Use STATICS rather than LOCAL variables

  

  • Function Modules - access is slightly more expensive than internal subroutines since you are loading another program.

 

  • Subroutines – Try to pass parameters by reference as much as possible. Specially when you pass internal table, try to pass the reference, unless you really need a copy of the table.

  

  • Use typed formal parameters, i.e parameters whose types are also defined in the subroutine declaration. This requires less CPU memory, reduces possibility of syntax errors and run time errors.

 

  • Calling methods of global classes is faster than calling  function modules

  

  • There is no performance loss when you call local methods compared to  local subroutines

 

 

8.  Thou shall know thy data types and use them prudently.

 

  • Use fields of type I for typical integral variables like indices.

  

  • Use numeric literals when you are dealing with type-I variables like sy-subrc instead of character strings.

 

  • Use properly typed constants instead of literals or variables. e.g.

CONSTANTS: PI TYPE F VALUE '3.1415926535897932'.

 

Instead of

DATA: PI TYPE F.

PI = '3.1415926535897932'.

 

  • Arithmetic : Use type-N fields only for pure digit strings that are not intended for calculations, e.g., telephone numbers or parts of a date or time field. For arithmetic operation, use type P or I.

 

  • Mixed Types

Don’t mix types unless absolutely necessary.

DATA: F1 TYPE I VALUE 2,

       F2 TYPE P DECIMALS 2 VALUE '3.14',

       F3 TYPE F.

F3 = F1 * F2.

 

Instead use all like data types.

 

DATA: F1 TYPE F VALUE 2,

       F2 TYPE F            VALUE '3.14',

       F3 TYPE F.

F3 = F1 * F2.

 

  • Unless rounding errors are not avoidable, do not use ‘packed’ data variables.

* Some of the examples here are from the Tips and Tricks provided in the report RSHOWTIM. Refer this report for more details.

 

9.  Thou shall foresee requirements, plan ahead and be well structured when writing an Object Oriented program.

 

  • In developing ABAP Objects, the ABAP language was cleaned up, in particular in the object-oriented contexts. The obsolete statements hence should not be used in Object oriented programs.

  

  • In object-oriented programming, analysis and design decisions have an even greater effect on implementation than they do in procedural programming. Therefore, you should structure and formally standardize the analysis and design phase. You can use modeling languages like Unified Modeling Language (UML) to do this.

 

The model has the following advantages:

. Improved software structure and consistency in the development process

. Reduced maintenance effort and less susceptibility to errors

. Better integration of the customer/user into the analysis, design, and

maintenance processes

. Options for extending the software are simpler and more secure

 

  • In classes, you can only use the TYPE addition to refer to data types. You can only use the LIKE reference for local data objects.

  

  • To get the maximum out of data encapsulation advantage of OOPs, try to declare as many attributes as possible as private.

 

  • To save run time, individual attributes are sometimes defined in the public visibility section, but they must then be given the addition READ-ONLY.

  

  • Functional Methods: Methods that have a RETURNING parameter are described as functional methods. They can have neither an EXPORTING nor a CHANGING parameter. The RETURNING parameter must always be passed by VALUE.

 

  • Constructors - Each class can have no more than one (instance) constructor.

                   . The constructor must be defined in the public area.

. The constructor's signature can only have importing parameters and  exceptions.

. When exceptions are raised in the constructor, instances are not created, so no main memory space is occupied.

. You cannot normally call the constructor explicitly.

 

  • There is no destructor in ABAP Objects, that is automatically called from the memory immediately before the object is deleted.

 

  • Changes made to super class at a later stage have an immediate effect on the subclasses; therefore, you must not alter the semantics when you change a super class.

  

  • When you assign a super-class reference to a subclass reference, you should always use widening cast assignment operator ‘?=’, since the subclass may contain more components than super class and hence super class may not be able to access all these components of subclass. When the widening cast operator is used all the components of the subclass can also be accessed, and there will not be a type cast error.

 

Data : obj_vehicle type ref to cl_vehicle,

            Obj_car type ref to cl_car.

 

cl_car is a subclass of super class cl_vehicle. It has attributes and methods in addition to the components of super-class cl_vehicles.

create object obj_vehicle.

obj_car ?= obj_vehicle.

 

Now though super class obj_vehicle is assigned to sub class obj_car, the widening cast operator, allows obj_car to access not only the components of obj_vehicle, but also of obj_car. (Polymorphism)

 

  • This polymorphism, that is, same object behaving differently can also be achieved using interfaces. Interfaces cannot be instantiated; interface reference can only refer to instances of classes that have implemented the interface. Here also, you must use the widening cast operator ‘?=’ when you want to assign a reference to interface to a class reference that has implemented the interface.

  

10.  Thou shall not be lazy nor shall thou give a tough time to thy fellow programmers in comprehending and enhancing the work of thy hands.

 

  • Write proper Documentation, so that any programmer who reads your program can easily understand what has been done. Insert comments at suitable points.

 

  • Use proper indentation. Make use of the Pretty Printer function to make your code look good.

  

  • Avoid hard coding literals, instead use constants. Will be easier for maintenance.

 

  • Understand the ABAP Debugger and efficiently use it after you are done with the program.
    • Static Analysis (Extended program check)

Example, for PERFORM / FORM

      • Checks that the called FORM exists
      • Checks that the number of actual and formal parameters matches
      • Checks that the parameter categories (USING, CHANGING, TABLES) match
      • Checks types
      • Checks whether a literal is called in a structured parameter or in the category CHANGING
      • Checks whether a FORM is called
      • Lists un-typed FORM parameters
    • Dynamic Analysis
      • ABAP/4 Run-time analysis
        • Tools-> ABAP/4 workbench ->Test->Runtime analysis (TCODE SE30)
      • Hints and Tips (Execute report RSHOWTIM)
    • Database Access
      • SQL (database) trace
        • Tools -> ABAP/4 workbench -> Test -> SQL trace (TCODE ST05)

Developer & Trial Editions: SAP Application Server ABAP and SAP Business Warehouse

$
0
0

Latest News

Feb 07, 2014: New developer edition of AS ABAP 7.4 SP5 incl. BW on SAP HANA SP7.

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

 

product_32.png

Get your hands on the latest release of SAP Application Server ABAP and SAP Business Warehouse, learn more about their latest capabilities, and test-drive the SAP Development Tools for Eclipse!

 

You can choose from different editions which are provided as pre-configured virtual appliances by the SAP Cloud Appliance Library (free of charge). SAP offers this software either based on the free developer license or a time-limited trial and evaluation license.

 

Get Your Free Virtual Appliance

 

These developer and trial editions of SAP Application Server ABAP and SAP Business Warehouse are available with different database flavors, i.e. on SAP HANA (in-memory database) and on SAP MaxDB. All virtual appliances come with detailed user guides describing how to set up and run these virtual appliances.

 

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

 

To get access to these virtual appliances and run them in your cloud service provider account, click on the links below to navigate to the corresponding SAP Store entries, log on with your SCN user, and hit the Demo Now button. For questions and feedback please post a message in the this thread.

 

tag_cloud_chart_grey_32.png

AS ABAP incl. BW 7.4 SP5 on SAP HANA SP7
[Developer Edition]

tag_cloud_chart_32.png

BW 7.4 SP5 incl. BI 4.1 SP3 on SAP HANA SP7
[30d Trial Edition]

tag_cloud_chart_32.png

AS ABAP 7.4 SP2 on SAP MaxDB 7.9
[90d Trial Edition]

tag_cloud_chart_grey_32.png

BW 7.4 SP2 on SAP MaxDB 7.9*
[90d Trial Edition]

 

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

 

Try Out These Sample Applications and Tutorials

 

All developer and trial editions come with a pre-configured users, pre-installed sample applications and tutorials explaining new capabilities and technologies.

 

study_leave_32.png

Please visit this page for more information about the available demo scenarios and tutorials. Of course, there are a lot of additional guides and tutorials offered by the community you may want to try out...

Viewing all 935 articles
Browse latest View live


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