Quantcast
Channel: ABAP Development
Viewing all 948 articles
Browse latest View live

Idoc in Cloud era.

$
0
0

In the era of cloud computing/web services, it may not be very stimulating to blog about IDOC ALV reports but I believe there are many organizations which still rely on that technology. I think there are still many global business teams supporting SAP who didn’t yet catch up with the emerging technologies.

 

I am sure that the headline of blog will leave many of us mulling over why we need to use this bespoke tool when SAP provides standard idoc error reporting and monitoring transactions. I am going to explain the gap and how the tool fills the gap for the business/technical ALE support teams in the next few sections.

 

Problem

Imagine you work in a big warehouse where stock keeps changing every second and it is important to determine the stock levels accurately for staying cut-throat in the market.  We had to build a goods movement ALE IDOC MBGMCR03 interface between legacy warehouse system and SAP ERP system that processes high volumes of goods movements to align the stocks and determine the stock levels accurately for running the business efficiently.

 

However things are not easy as they are said, the legacy systems as you expect are so fragile and hence the interface always had few hundreds of errors that needs to be resolved by the support teams. While the legacy teams are working hard to resolve the interface defects, the business teams have to resolve the IDOC errors manually and align missing stocks between the legacy warehouse and SAP system.

 

It was quite laborious and time consuming for the support team to drill down each goods movement IDOC and segments to identify the stocks that are misaligned via the transactions WE02 and WE09 and align the stocks manually between the legacy warehouse and SAP ERP system.

 

Solution

I thought the solution to the problem is ideally to provide the business with an IDOC ALV error report that displays IDOC Number, IDOC Status, IDOC Status Text and IDOC Segment Field and the value in the IDOC Segment Field. It will be more useful for the business users if he has an option to choose the IDOC segment fields and the filter the IDOCS based on the values in the segments.

 

I had done some research on the internet to check whether there are any blogs or SAP transactions that will do this but unfortunately found none. I found the standard report RSECHK05 but it doesn’t either give you a list of error IDOCS for a message type or an option to the user to select the IDOC segment fields or filter the IDOC content that he is interested to see in the ALV output.

 

The program RSECHK05 provided me a good starting point to develop a tool that works for any IDOC message type.



Keyboard tips when coding

$
0
0

Hi ,

 

         I added two keyboard tips used frequently , when i am coding.    

 

-       When we are coding sometimes we need to copy and paste the pervious line to next line to change the code.

 

        E.g :-    Data : c_1 type c,

                             c_2 type c,

                             c_3 type c.

 

         In such cases ,  usually we will copy the previous line and paste below.

 

         Instead of that use ' CTRL + D'  - which will duplicate the row.

 

                tips.jpg

 

 

-      Sometime after coding  we need to go to command field and type some tcodes for testing.

 

         Instead of select the mouse and click at command field , Use 'CNTL + /'

 

                tips2.jpg

 

- There are lot of keyboard setting tips where SAP is providing , but many of them are not easily remembered or used. Please share some more tips below which  are used at the time of coding other than CTRL + C  and CTRL + V ........ :-)

Create a PDF from Spool and Transfer to Client server Using FTP .

$
0
0

Hello All ,

 

I found a lot of questions being raised on transferring the PDF file through FTP. Please use the code below i have developed for my project it works! .

 

 

 

START-OF-SELECTION.

 

   IF ftp EQ 'X'.

 

*subroutine for ftp transfer

     PERFORM : spool_pdf_conversion.

*              ftp_transfer .

   ELSE.

 

*subroutine for local transfer

     PERFORM : spool_pdf_conversion,

               local_transfer .

 

   ENDIF.

 

 

 

 

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

*&      Form  spool_pdf_conversion

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

*       text

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

FORM spool_pdf_conversion.

***convert spool to pdf

  CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

    EXPORTING

      src_spoolid              = spoolno

      no_dialog                = 'X'

      pdf_destination          = 'X'

      no_background            = 'X'

    IMPORTING

      pdf_bytecount            = bin_size

      bin_file                 = pdf_xstring

    EXCEPTIONS

      err_no_otf_spooljob      = 1

      err_no_spooljob          = 2

      err_no_permission        = 3

      err_conv_not_possible    = 4

      err_bad_dstdevice        = 5

      user_cancelled           = 6

      err_spoolerror           = 7

      err_temseerror           = 8

      err_btcjob_open_failed   = 9

      err_btcjob_submit_failed = 10

      err_btcjob_close_failed  = 11

      OTHERS                   = 12.

  IF sy-subrc <> 0.

    MESSAGE e712(po) WITH sy-subrc 'CONVERT_OTFSPOOLJOB_2_PDF'.

  ENDIF.

 

 

***converting xstring to the binary format

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

    EXPORTING

      buffer                = pdf_xstring

*       APPEND_TO_TABLE       = ' '

*     IMPORTING

*       OUTPUT_LENGTH         =

    TABLES

      binary_tab            = bindata

            .

 

 

ENDFORM.                    "spool_pdf_conversion

 

 

 

 

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

*&      Form  Desktop_transfer

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

*       text

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

FORM LOCAL_transfer.

 

 

  CALL FUNCTION 'FTP_R3_TO_CLIENT'

EXPORTING

   fname                 = 'C:\Documents and Settings\GSS\Desktop\Script_d.PDF'

   rfc_destination       = 'SAPFTP'

  blob_length           =  bin_size

*     CHARACTER_MODE        = 'X'

TABLES

   blob                = bindata

*    TEXT                  =  datatab

EXCEPTIONS

  command_error         = 1

  data_error            = 2

  OTHERS                = 3.

 

 

 

 

ENDFORM.                    "Desktop_transfer

 

 

 

 

 

 

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

*&      Form  ftp_trasfer

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

*       text

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

FORM ftp_transfer.

 

 

***ftp connection logic

  slen = STRLEN( l_pwd ).

 

 

  CALL FUNCTION 'HTTP_SCRAMBLE'

    EXPORTING

      SOURCE      = l_pwd

      sourcelen   = slen

      key         = key

    IMPORTING

      destination = l_pwd.

 

 

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

    EXPORTING

      text = 'Connect to FTP Server'.

 

 

  CALL FUNCTION 'FTP_CONNECT'

    EXPORTING

      user            = l_user

      password        = l_pwd

      host            = l_host

      rfc_destination = 'SAPFTPA'

    IMPORTING

      handle          = hdl.

 

 

  IF NOT pasv IS INITIAL.

    REFRESH result.

 

 

    CALL FUNCTION 'FTP_COMMAND'

      EXPORTING

        handle        = hdl

        command       = 'set passive on'

      TABLES

        data          = result

      EXCEPTIONS

        tcpip_error   = 1

        command_error = 2

        data_error    = 3.

 

 

    IF sy-subrc EQ 0.

      WRITE: / 'Set passive mode'.

      SKIP 1.

    ENDIF.

 

 

  ENDIF.

 

 

***passing the file name

  docid = 'Script.pdf'.

 

 

***connecting to the ftp server

  CALL FUNCTION 'FTP_R3_TO_SERVER'

    EXPORTING

      handle        = hdl

      fname         = docid

      blob_length   = bin_size

    TABLES

      blob          = bindata

    EXCEPTIONS

      tcpip_error   = 1

      command_error = 2

      data_error    = 3

      OTHERS        = 4.

 

 

***ftp disconnection

  CALL FUNCTION 'FTP_DISCONNECT'

    EXPORTING

      handle = hdl.

 

 

  CALL FUNCTION 'RFC_CONNECTION_CLOSE'

    EXPORTING

      destination = dest

    EXCEPTIONS

      OTHERS      = 1.

 

 

ENDFORM.                    "

 

 

******* Declarations.

 

TYPES: BEGIN OF blob,

       line(80) TYPE x,

       END OF blob.

 

 

*** PDF conversion Declaration .

DATA: pdf_size      TYPE so_obj_len,

      pdf_content   TYPE solix_tab,

      pdf_xstring   TYPE xstring,

      v_xstring     TYPE xstring,

      v_text      TYPE localfile,

      rq       TYPE tsp01,

      bin_size TYPE i,

      dummy    TYPE TABLE OF rspoattr,

      otf LIKE itcoo OCCURS 100 WITH HEADER LINE,

      cancel,

      pdf LIKE tline OCCURS 100 WITH HEADER LINE,

      doctab LIKE docs OCCURS 1 WITH HEADER LINE,

      numbytes TYPE i,

      arc_idx LIKE toa_dara,

      pdfspoolid LIKE tsp01-rqident,

      jobname LIKE tbtcjob-jobname,

      jobcount LIKE tbtcjob-jobcount,

      is_otf,

      client LIKE tst01-dclient,

      name LIKE tst01-dname,

      objtype LIKE rststype-type,

      type LIKE rststype-type,

      get_size_from_format,

      bindata TYPE TABLE OF blob WITH HEADER LINE,

      result TYPE TABLE OF text WITH HEADER LINE,

      filesize TYPE i,

      convcount TYPE i,

      lines LIKE tline OCCURS 100 WITH HEADER LINE,

      textlines LIKE tline OCCURS 100 WITH HEADER LINE,

 

 

***FTP declarations

      v_file     TYPE char40,

      w_hdl      TYPE i,

      c_key      TYPE i VALUE 26101957,

      l_slen     TYPE i,

      l_user(30) TYPE c VALUE 'USERNAME',                    "user name of ftp server

      l_pwd(30)  TYPE c VALUE 'PASSWORD',              "password of ftp server

      l_host(64) TYPE c VALUE 'IP_ADDRESS',      "ip address of FTP server

      pasv,

      key TYPE i VALUE 26101957,

      hdl TYPE i,

      slen TYPE i,

      x TYPE i,

      docid LIKE sysuuid-c,

      cmd(120),

      error,

      bline(120) TYPE x,

      dest LIKE rfcdes-rfcdest.

 

 

***Selection Screen

PARAMETERS: spoolno LIKE tsp01-rqident.

 

 

SELECTION-SCREEN BEGIN OF LINE .

SELECTION-SCREEN POSITION 2.

PARAMETERS: ftp RADIOBUTTON GROUP rb.

SELECTION-SCREEN COMMENT 5(45) text-005.

SELECTION-SCREEN END OF LINE.

 

 

SELECTION-SCREEN BEGIN OF LINE .

SELECTION-SCREEN POSITION 2.

PARAMETERS: local RADIOBUTTON GROUP rb .

SELECTION-SCREEN COMMENT 5(45) text-006.

SELECTION-SCREEN END OF LINE.

 

Thank you .

ABAP News for Release 7.40 - ABAP Doc for ADT

$
0
0

ABAP Doc is a simple documentation tool similar to Javadoc that enables documentation in HTML format to be created automatically from ABAP source code. ABAP Doc is based on special ABAP Doc comments.

 

 

ABAP Doc comments

 

A comment for ABAP Doc is introduced with "!. An ABAP Doc comment (a line or a block of lines) must be linked to exactly one declaration statement.

 

Example

 

"! Basic usage of ABAP Doc

CLASS demo DEFINITION.

  PUBLIC SECTION.

    "! Constant character string for a single blank.

    CONSTANTS blank TYPE string VALUE ` `.

    "! Method to fill the private structure struct with values

    "! and append it to internal table itab.

    METHODS meth.

  PRIVATE SECTION.

    DATA:

      "! Three-component structure

      BEGIN OF struct,

        "! Component one

        comp1 TYPE i,

        "! Component two

        comp2 TYPE i,

        "! Component three

        comp3 TYPE i,

      END OF struct,

      "! Internal table of structure struct

      itab LIKE TABLE OF struct.

ENDCLASS.

 

There is a special syntax for the parameter interface of procedures and of events.

 

Example

 

"! Method to check if two sources are identical

"! and that returns a corresponding boolean value.

"!

"! @parameter source1     | First source

"! @parameter source2     | Second source

"! @parameter ignore_case | Pass abap_true to ignore case

"!

"! @parameter result      | Returns abap_true if sources are identic

"!

"! @raising   cx_invalid_source

"!                        | One of the sources is empty

METHODS compare

  IMPORTING

    source1       TYPE text

    source2       TYPE text

    ignore_case   TYPE abap_bool DEFAULT abap_false

  RETURNING

    VALUE(result) TYPE abap_bool

  RAISING

    cx_invalid_source.

 

A subset of HTML-Tags can be used for formatting.

 

Example

 

"!<h1>Class demo</h1>
"!<p>This class must <strong>not</strong> be used productively.</p>
"!The class serves the following tasks:
"!<ul><li>Demo 1</li>
"!    <li>Demo 2</li>
"!    <li>Demo 3</li></ul>
"!<br/><br/>
CLASS demo DEFINITION.
  ...
ENDCLASS.

 

The syntax rules of ABAP Doc are checked by the ABAP syntax check.

 

 

ABAP Doc display

 

ABAP Doc comments are evalutated in the ABAP Editor of the ABAP Development Tools (ADT, aka ABAP in Eclipse) but not in the ABAP Editor of SAP GUI (SE80 & Co.). If you place the cursor on an entity that is documented by ABAP Doc comments and hit F2, the formatted documentation is neatly shown in a popup window.

 

ABAP_Doc.png

The ABAP Doc mechanism overwrites the display of eventually existing classical class or method documentation.

 

 

Remarks

 

My SAP-buddy Thomas Fiedler won't like it but I have some remarks to add.

 

I really like ABAP Doc, but

 

  • it is evaluated in ADT only. If you use ABAP Doc you must be sure that the users of your APIs work in ADT only. In SAP GUI they see the comments but not the formatted documents where they are needed.
  • ABAP Doc hides existing classical class builder documentation (short and long texts). Before using ABAP Doc you should have a look if there is documentation already available  (OK, OK, this is rarely the case ...)  and whether you want to reuse it. Up to now, there is no migration tool available.
  • The old way of documenting classes and methods has some benefits too: Short description in short texts. Detailed description in long texts including examples for usage and possibility of linking to other documents. Do you want to place example programs in ABAP Doc? Up to now, there is no integration concept that enables the developer to exploit best of both worlds.

 

That's why I continue to document my classes with long texts in the classical class builder. Maybe I'm a dinosaur but hopefully not yet dying out .

 

I tend to say that in its present state ABAP Doc is a good tool for developers who would never document in class builder anyhow (independent of SAP GUI vs. ADT). Such developers have a simple support for documenting by commenting now. Any kind of documentation is better than no documentation.

 

Any remarks from your side?

 

 

-

ABAP News for Release 7.40 - ABAP Keyword Docu for ADT

$
0
0

Sometimes even ABAP developers don't know the syntax and semantics of their beloved ABAP statements by heart and need some help (statistics show mostly for DELETE). Then they are used to click F1 on a statement in the ABAP Editor and miraculously the ABAP Keyword Documentation appears. That's old hat in SAP GUI but what about ADT (aka ABAP in Eclipse)?

 

 

ABAP Keyword Documentation in ADT

 

The good news is: Using F1 on a statement in ADT displays the ABAP Keyword Documentation in a panel of Eclipse. You might have taken that for granted, but in fact it is not. The text and the structure of the ABAP Keyword  Documentation is delivered as database contents with every AS ABAP. In the classical ABAP Workbench there is a framework for handling and displaying these texts that evolved over years. It includes different search capabilities, and some goodies as exceuting example programs directly from the docu display. Of course, this framework totally depends on SAP GUI. E.g. executing an example program is not such a big thing there, since you simply can use aRFC to SUBMIT it in another session. For output purposes one could simply use WRITE and it worked. You can imagine that nothing of this is possible in Eclipse just like that.

 

Fortunately, there was a lucky coincidence. Some years ago I simply wanted to send around links to topics of the documentation within SAP. Many questions that arise in daily work or during hotline service can be answered by pointing to the documentation ("Read the ... manual!"). Since it is not possible to point to the SAP GUI Documentation from outside of the system, I enhanced the docu framework in such a way that it is able to produce a docu version that is accessible via http (in fact it emerged from the older offline version that you can dowmload from the GUI version yourself and that you also find here).  You find the respective path "/sap/public/bc/abap/docu" in transaction SICF since Release 7.02 and you can test it with program ABAP_DOCU_WEB_VERSION.

 

Now guess what the ADT developers did in order to enable the ABAP F1 help? They were simply calling my http-service! And suddenly my personal plaything became a real product that I have to maintain (arrgh). It is clear, that my crude first version was not good enough for such an usage and lots of improvements had to be applied. E.g., the format had to be adjusted to Eclipse or the display of the tree structure, that is available in the SAP GUI version, had to be converted into breadcrumbs shown at the top of each document in order to enable navigation. With ADT for Release 7.31, a first working version of that documentation display is avaliable. For Release 7.40 some improvements were applied.

 

 

Improvements for 7.40

 

The aim is that the display of the ABAP Keyword Documentation in ADT will cover the same functionality as the SAP GUI Version. For Release 7.40 the following milestones were reached.

 

Context sensitivity

 

If you compare the context sensitivity of the ABAP F1 help between ADT and SAP GUI in Release 7.31 you find that the result in ADT is much less context sensitive. The reason is that ADT delivers only the word that was clicked while SAP GUI delivers the full statement. E.g. F1 on FROM in SELECT in ADT gave a list of all FROMs in ABAP. With Release 7.40 the docu call in ADT was tweaked in such a way, that now also the context of the clicked word is delivered. As a result the context sensitivity is the same in ADT as in SAP GUI. F1 on FROM in SELECT shows the respective documentation in ADT as you would expect it from SAP GUI.

 

Permanent input field

 

Since Release 7.02, the SAP GUI version of the ABAP Keyword Documentation shows a permanent input field in the upper left corner above the tree structure (up to 7.0, you had to choose the binocular icon to display the field in a popup box). Once you get used to it you won't miss it. But how to input a query in ADT? Did you know that in Release 7.31 you can navigate to the Entry page in order to enter a term? With Release 7.40 an input field is offered in the right upper corner of each document display now (took me some time, because all this html/js-stuff is handmade in ABAP ...):

 

InputField.png

 

Executable examples

 

This was a personal challenge. The ABAP Keyword Documentation contains a large example library with all examples readily executable from the SAP GUI version. In SAP GUI a piece of cake, because example in- and output can be done in SAP GUI too. But how to run examples with input and output from documentation displayed in a browser ? (the Eclipse panel is nothing but a browser)

 

Again a lucky coincidence. The classes CL_DEMO_INPUT and CL_DEMO_OUTPUT that I've developed for a different purpose perfectly matched also those needs. Input and output are based on HTML and this can be handled with an http-service. As a result, all example programs that work with CL_DEMO_INPUT and CL_DEMO_OUTPUT (instead of PARAMETERS and WRITE) are automatically executable from the ADT docu display now (and are still executable in SAP GUI display, of course).

 

Execute example

Exa1.png

 

Enter input

 

Exa2.png

 

See output

 

Exa3.png

 

Wowee!

 

And since Eclipse exploits a generally available http-service this documentation display including executable examples is not restricted to ADT alone!

 

Exa4.png

 

Even dinosaurs like to play

Find the BADI for the particular TCODE quickly

$
0
0

Hi ,

 

  - Go to TCODE SE24 and enter the class name 'CL_EXITHANDLER'.

 

- Go to the class in Display mode and Select 'GET_INSTANCE' method

 

   badi1.jpg

-   Now place a breakpoint at the statement

        

             CALL METHOD cl_exithandler=>get_class_name_by_interface

 

     badi2.jpg

 

  - Now , run the TCODE  for which we need to find the BADI.

 

  - Later in the debugger , find the value for exit_name parameter.

 

    It shows one of the badi for that TCODE , because each tcode will be linked to multiple BADIs.

 

EDI errors - First Record is not a control Record

$
0
0

The error is that the first segment is not the right one and the creation stops .

 

 

The error that was encountered was when the loading file .idoc file error ed out and was replaced by a another .idoc file .

This file also error ed out and the incoming sales orders were not created.

The files names were the same and on further analysis it was realized that the reason for changing the file was that the first one had errors in the EDI segments.

The client had replaced the file with the same name and assumed that the file would resume from the error that happened in the first file but this failed .

The error happens as the system tries to restart processing from the line number where the last successful idoc was created but because the file name is the same and the lines have changes system cannot find the starting segment and errors out.

 

 

Solution.

 

The solution for this issue is to make the program start reading the new file that was loaded in this case in2.idoc from line 1 where the EDIDC segment is present and not a different line. This can be done by following the steps below.

 

 

Step 1.

Please login into tcode se11.  Enter EDFI2 as the database table.

Step2.

Please press CTRL+SHIFT+F10 together to display the contents and Press F8.

Step3.

Confirm that the path that the in2.idoc file exists in the database as a entry and check the last created idoc number.

Step4.

Once confirmed that the entry exists go to se37 and enter EDI_EDFI2_DELETE   as the Function Module and press Display. Then execute by pressing F8.

Step5.

Enter the path name and check the upper/lower case button and press F8.The result should come up as database entry deleted.The path number is from the table discussed earlier.

Go back to the database EDFI2 to check that the entry has been deleted .Now trigger the program to process the 2.idoc file.

 

 

 

This should resolve the error as the counter that was maintained in the table was cleared making the system read the file as a new file and not associate it with the old file .

 

Please feel free to ask me any doubts you may have about this blog .

 

Thank you

Configuration of WEBDYNPRO as Client Proxy

$
0
0

hii frds,

          

The steps required to configure an ABAP Webdynpro as a client proxy. Question me, Why an integration experts need to use ABAP Webdynpro for a client proxy? Have the answer!

I have been asked by the customer to provide an application that can pull up the employee information from SAP and 5 legacy systems based on search term that will be fed by her. The user is from MI team and she does not want to login to SAP nor see the ABAP SE38 Screens. Immediately solution that I bestowed her is to use ABAP Webdynpro that allows her to search the information by shielding her logging onto various systems. Objective is to make the customers happy, Isn&#146;t it?

Do you agree with me that learning ABAP Webdynpro and using it as a client proxy will be beneficial to you as an integration expert? If you disagree then please abort then the blog might not be useful for you.

I assume that you know how to create ABAP Webdynpro components, views, context structures and bind the UI elements to the context structure of the view.If you don&#146;t know then it is not a danger. Read this series.

I am going to take the same interface that is provided by ravi in  for simplicity with the only difference being the files is simulated only when user enters the employee number, employee name and department name and press simulate file.I donot discuss the configuration and mapping details here as they remain exactly same. You need to just plug an ABAP Webdynpro in place of a proxy.
Steps Required :
1 .Create a Webdynpro  Component ZABAPWDClientProxy.
2. Create Context Structure as shown below.

  context

> cempno

> cename

> cdeptname

 

3. Create View InitialView and create 7 UI elements Label for Employee Number, Label for Employee Name, Label for Department Name, InputTextbox for Employee Number, InputTextbox for Employee Name, and InputTextbox for Department Name and Simulate file button that triggers the proxy. After creating the UI elements, bind them to the context structures and associate event SIMULATEFILE to the button.

 

4. Now paste the source code provided below in the method SIMULATEFILE by selecting action tab.

 

data prxy type ref to zblogco_proxy_interface_ob.create object prxy.data it type  zblogemp_profile_msg1.wd_context->get_attribute( exporting name  = 'CEMPNO'  importing  value = it-emp_profile_msg-empno ).wd_context->get_attribute( exporting name  = 'CENAME'  importing  value = it-emp_profile_msg-emp_name ).wd_context->get_attribute( exporting name  = 'CDEPTNAME'  importing  value = it-emp_profile_msg-department_name ).try. call method prxy->execute_asynchronous      exporting        output = it.   .  catch cx_ai_system_fault .    data fault type ref to cx_ai_system_fault .    create object fault.    write :/ fault->errortext.endtry.

 

5. Create Webdynpro application and feed in the sample data and you can see the file in the folder you configured if your configuration is correct.

 

 

Thanks,

Regards,

Deepak Singh


A simpler way to display transport logs

$
0
0

When working on changes to a report, table, class or any transportable object in SAP, it has often been found that some objects are not transported correctly or they are just stuck in quality system which the developer / basis forgot to release. This may not always cause a problem in production environment but can create a confusion. It also doesn't look neat if some transports are forgotten and gives the customer an impression of the inefficiency of the technical team.

 

To circumvent the issue I had once created a report in development system to help us view the transport logs of existing changes in an easier way. Generally we have to go to SE10, click on transports of each object or go to version history and check the logs. This report does all of this and displays the result in a tabular form.

 

Given below are the steps to follow on how to check for transport logs.

*   Suppose we want to check the version history and the corresponding transport logs for the INCLUDE report ZXVEDU03. We go to SE38 and execute the report ZTRANSLOG.

*   In the selection screen we provide the object name and select Report and Report texts radio button.

image002.jpg

*  After executing the report we will get a tabular display of the transport numbers associated with the version history (latest on top). Before starting development on an object we must make sure that other developers are not working on them concurrently. In case there is, we will find the object released from CMD(development) in the topmost log entry. It may or may not have reached quality, but if it has not reached production it could cause an issue if case we decide to continue with our development ignoring dependency.

 

image004.jpg

 

In case you want to use the same report or just take it on a test run make sure to maintain the ALV fieldcatalog in the report correctly. It has been provided in the attachment.

 

For this you need to adjust the internal table i_alv, modify the calls the the form to_light and also adjust the form build_fieldcat.

 

For example, in my scenario, i had a development system CMD and a test system CSG. The east chain is CTC -> CAC ->C0C and west chain is CT5 -> CA5 -> C05 in development -> quality -> production manner. The green lights indicate that the transport have reached successfully in that system, yellow indicates transportation with warning and red is an error. A blank indicates that it has not been transported to the system.

 

If you want to build this kind of report from scratch, just to give you a lead, you might take a look into the functionality of the two function modules:

1. TR_OBJECT_TABLE

2. SVRS_GET_VERSION_DIRECTORY_46

 

These 2 function modules are the heart of the development.

Creating ABAP proxies.

$
0
0

The main bottleneck of ABAP Proxies is the amount of custom coding that is required. Though we cannot get away with it I will try to organize the coding in a better fashion over here.

Though out of context here, I would like to put few of thoughts on most of the questions raised in forum posts while choosing ABAP proxies:

Lot of debating happens when the XI developers need to choose between RFC adapters or Idoc adapters or Proxies. I will try to propose a solution out of my little experience and I leave the decision to the readers what has to be chosen in their projects.

It is very clear that proxies comes into context only when WAS >= 6.2.But we can still use Idoc adapter or RFC adapter for communicating with SAP systems having WAS >=6.2!! That calls for a problem, as there are too many options. What is the best option out of it?

My Recommendations:
1.Use Idoc adapter if standard idoc is available to meet the business requirements.
2.Use RFC adapter if the data volume is less and there are standard BAPI&#146;s available to achieve the functionality otherwise we face critical performance bottlenecks.
3.Best option is to use a proxy while handling large volumes and developing a custom business processes.

 

Coding Proxies in a better way:

ABAP Proxies in XI(Client Proxy) has to be read before understanding this as the idea presented here is an enhancement to the blog and same proxy object is used for demonstrating in a more understandable fashion.

The disadvantage of proxy is that it involves lot of custom coding and we need to educate the ABAPer&#146;s to code the proxies. We can see that SAP NW is going towards Object Orientation but still we code traditional reports for executing every proxy.

Do I need to write 80 reports for executing 80 proxies and do I need to schedule 80 reports incase of client proxies? Can we design proxies in a smarter way? Yes. Check this sample code, which will take the proxy name and generates the proxy code automatically that triggers the client proxy.

 

code :

*&---------------------------------------------------------------------**& Report  YPROXIES                                                    **&                                                                     **&---------------------------------------------------------------------**&                                                                     **&                                                                     **&---------------------------------------------------------------------*REPORT  yproxies.********************Data Declarations********************TYPES: line TYPE string.DATA: itab TYPE STANDARD TABLE OF line.DATA LINE TYPE LINE.PARAMETERS:p_int(50) TYPE c.***********************************************************************Code for Triggering Proxie dynamically********************APPEND 'REPORT  ZABAPPROXY.' TO itab.CLEAR line.CONCATENATE 'DATA prxy TYPE REF TO' p_int '.' INTO line SEPARATED BYspace.APPEND line TO itab.APPEND 'CREATE OBJECT prxy.' TO itab.APPEND 'TRY.' TO itab.APPEND 'CALL METHOD prxy->execute_asynchronous.' TO itab.APPEND 'commit work.' TO itab.APPEND 'CATCH cx_ai_system_fault .' TO itab.APPEND 'DATA fault TYPE REF TO cx_ai_system_fault .' TO itab.APPEND 'CREATE OBJECT fault.' TO itab.APPEND 'WRITE :/ fault->errortext.' TO itab.APPEND 'ENDTRY.' TO itab.INSERT REPORT 'ZABAPPROXY' FROM itab.GENERATE REPORT 'ZABAPPROXY' .SUBMIT  zabapproxy .DELETE REPORT 'ZABAPPROXY'.***********************************************************************

 

 

This report can be used to trigger any client proxy .All we need to do is to just feed the proxy name.In SE24, We have to write proxy/interface specific code for the object. Here we abstracted the triggering of proxies from application logic.

 

Screen dumps:

Create the report YPROXIES in se38 editor with the source code provided above. Fill the text elements as shown in the below figure.

Text Elements

Fill in the proxy class name details as shown below and press F8, which will trigger the proxy:

Exec generic Proxy

Application proxy logic is written in the proxy itself as depicted below:

App Proxie

 

 

Best,

Abhijeet Kankani

What Functional Should know Technically

$
0
0

My idea is to pen down some common knowledge which i feel the Functional Consultant should know Technically.

It is very common in SAP projects where a functional and technical consultant sit across to discuss and design the developments.

A few pointers i want to highlight to the Functional Consultant to deepen there understanding about a development.

1. Architecture of SAP Product is very important from technical understanding point of view. One needs to be well versed with the workprocesss, as this can help knowing what happens after we run a transaction.


2. Whatever transactions a functional consultant runs on the SAP screen, if same needs to be done via a development then BAPI is the choice

Now to find out that one good way is to find out the IMG node for the process and generally SAP has given a list of enhancement as a node.

BAPI takes care of all the config made by the functional consultant

3. If a functional consultant wants some changes in the standard SAP process then it can be achieved using user-exits or BADI. in the point 2 even if we use BAPI to run the transaction programatically the BAPI will take care of the implemented BADI and user-exit.

 

4. Now an even powerful framework which SAP has given is Enhancement framework consisting implicit enhancement, explicit enhancement, pre-exit, post-exit and kernal BADIs. Lets say if a functional requirement is such that it is not meeting through exit and BADI, one can use the implicit and explicit enhancement but carefully, as we can alter the data in the hazardous manner, so the intigrity lies in the hand of the consultants.

 

5. A common troubleshooting of a program using BAPI which is not giving the desired result is to run the transation over the screen to ensure if it is happening correctly there, it has to work correctly with BAPI.

 


The above points i feel helps build the understanding of the functional consultant to pin point the correct solution approach broadly in case he is opting for a development.

Transfer Order stuck with Zero Quantity - Not able to Delete / confirm -Stuck in RFC Gun

$
0
0

The error happens sometimes when the Transfer Order is created through a RFC gun . The TO is created but the line item has zero quantity ( Red Dot ). This is a tricky situation as the TO cannot be cancelled or confirmed and the TO is stuck in the RFC gun .

 

Solution.

 

The line item has to be cancelled for the TO to be processed with .

 

Steps .

1.Go to SE11 enter LTAP and enter the TO number along with the Warehouse Info .

2.Change to layout to Standard List and double click on the TO to display the details

3.Trigger the debugger using /H press enter . Then press enter again to open the debugger .

4. The variable CODE would have value SHOW  change it to EDIT and press enter .Then Press F8

5. The values in the list would now be open for  editing

 

Note : Please make sure that you take a snap shot of all the values in the DB before you make any changes as these steps should be taken as the last

          resort .

6. Change the values for the below fields .

7.      pquit =

8.      qdatu = sy-datum
9.      vorga = 'ST'

10.    vsolm = 1
11.    vdifm = -1
12.    nsola = 1

13.    passd = 'X'

 

Save the changes .

 

After this if you go into the Transfer Order you will see that the line items has been deleted and you can proceed.

 

If all lines items are zero quantity and appear with a red dot then repeat the steps above for all the line items and also do the steps below.

 

14. Go to SE11  enter LTAK and enter the TO number with the Warehouse Info .

15. Repeat the steps from 3 to 5 .

 

 

Note : Please make sure that you take a snap shot of all the values in the DB before you make any changes as these steps should be taken as the last

          resort .

 

16.     kquit = 'X'
17.     qdatu = sy-datum
18.     passd = 'X'  .

 

Save the changes . The TO is now deleted as all the lines items will have the bin symbol next to it . If a  delivery exits the WH status would be set to C .

 

If the TO is stuck in the Gun then do the next steps in the LTAK table .

 

19 . queue = ' '

 

Save the changes .

 

This completes the exercise and please email me if you have any doubts .

 

Thank you

 


 



 

 


ASCIIDOC - Small and handy documentation tool

$
0
0

I've been developing ABAP code for over 7 years now, and it amazes me how much time is lost creating documentations worth nothing. Most times projects don't know how to properly document their source-codes. They require you use ugly templates with tons of information that get's old as soon as they are typed in the word document. A lot of time and money wasted, writing something nobody will ever use.

 

Well, that's enough for my rant . I already wrote a huge rant about documentation outside SCN, on my personal blog (written in brazilian portuguese, this link is from google-translator). This is just to give you a little background on why I started looking for alternatives. This year my professional life turned upside-down due to a lot of reasons, but in the end I was lucky enough to stay in a team where we can use whatever tool we judge is best to get the task done. And that's how I find ASCIIDOC.


 

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

 

ASCIIDOC?

 

ASCIIDOC is a small and free tool created in python. Basically it's a script that can read a source text file written in a particular way, and generate a cool output in a variety of formats. You can create HTML, PDF and even ePUB files (some of them use DocBook as a base for conversion). You can also specify a .CSS file as a template.

 

ASCIIDOC'shomepage has a huge and detalied documentation with everything this small tool can do. You can get an overview clicking here.

 

 

Small Example

 

In the past, everytime I started writing a technical document I always thought that I wanted to keep it as simple as possible. I don't need tons of fancy stuff (hate those crazy templates), what I need is a fast way to explain how my application works.

 

If you're into pc/console gaming, odds are you know well an website called GameFAQs.com . It has tons of Walkthroughs, Charts and Guides for a HUGE amount of games. Check out these guides, for Castlevania: Symphony of The Night (one of my favorites of all times). That's almost exactly what I always wanted for my coding documentation: relevant information in small and simple files.

 

Let's see what we can do with ASCIIDOC. After you've installed the tool, copy the contents of this web page to a new text file. Then open the command line at the folder you saved the file, and run asciidoc <filename>.

 

This command will give you this output. Cool isn't it?

 

At the top of the text file, there are some words with two ":" in it, like :toc2: . Some are backend attributes, that you can specify either in the file or at the command line (e.g. :toc2: wich creates the table of contents would be asciidoc -a toc2 <textfile> in the command line ).  The other ones are "variables": I can change the value for :myemail: only once at the top, and every place in the document where I used {myemail} would also get changed.

 

Creating topics is really easy, you just have to underline the title according to the sequence: "==" is the document title, "---" is the main topic and "~~" is for the sub-topics. There are tons of options, like tables, links, images, thumbnails, cross references, bulleted lists and so on. Checkout the ASCIIDOC Cheatsheet for a list that covers the most used commands.

 

 

Usage

 

First of all, once you create your own .css file documents get a very "professional style", but are still lightweight files. I've created a template for my company and it works great.  I can also create a .pdf and send to my clients, or keep the .HTML on our server for a fast and nice way of checking the documentation.

 

I'm finding it really easy to maintain the documentation files, because ASCIIDOC uses a very intuitive formatting. In addition to an enhanced text file editor, like Sublime Text 2, it's even easier (there's a plugin for ASCIIDOC format highlighting). It's simple and fast to deliver new documents as I don't have to care about templates and such, just format the information in a way it's easy to read and it's good to go.

 

Your going to use the command line a lot with ASCIIDOC, so it's propably not the best tool for end users. But hey, you can always create some shell scripts or batch files (which I used a LOT when creating my own .css template).

 

 

 

Alternatives

 

I know ASCIIDOC may not suit everyone needs. So I'm guessing some of you may also have cool alternatives to software documentation. Hopefully you'll share those hidden gems with us on the commentaries.

 

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

 

Thank you and see you next time!

Consuming WebServices directly from ABAP

$
0
0

A time ago I was asked to create a Webservice consumption directly from ABAP without any soa.

 

We listen too much about SAP PI as an integrator and every SAP connection is done thru it (that's the best way to do it, I think) but it is not the only way. Since ERP 4.7  it is possible to consume/provide services directly from ABAP.

 

When our scenario is SAP -> WebService the first thing we need is a working webservice.

Test service:

 

Here I'll create a Service Consumer for consumption of a test webservice from http://www.webservicex.net/length.asmx?WSDL it's service that converts lenght units.

 

First, let's take a better look to the WSDL:

In this file there are 3 operations:

  • lengthUnitSoap
  • lengthUnitHttpGet
  • lengthUnitHttpPost

 

For this post the only relevant port service is lengthUnitSoap that implements Soap standards. The two others are for HTTP consumption directly (not our focus here).

 

Before we can simply import our file to SAP, taking a better look into it we see that some messages have more than one part tag:

1.png

This kind of message is incompatible with SAP, so if there are any messages with more than exactly one part tag the system will return you an error before import your file. Even if the message is not used in the service that you are implementing.

 

In thes scenario what can we do?

 

Simple: we can edit the file to match our needs.

 

Save the original WSDL file to your computer (as .xml or .wsdl) then edit it.

 

The editted WSDL file shoud seem like this:

 

<?xml version="1.0" encoding="utf-8"?><wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.webserviceX.NET/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">  <wsdl:types>    <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">      <s:element name="ChangeLengthUnit">        <s:complexType>          <s:sequence>            <s:element minOccurs="1" maxOccurs="1" name="LengthValue" type="s:double" />            <s:element minOccurs="1" maxOccurs="1" name="fromLengthUnit" type="tns:Lengths" />            <s:element minOccurs="1" maxOccurs="1" name="toLengthUnit" type="tns:Lengths" />          </s:sequence>        </s:complexType>      </s:element>      <s:simpleType name="Lengths">        <s:restriction base="s:string">          <s:enumeration value="Angstroms" />          <s:enumeration value="Nanometers" />          <s:enumeration value="Microinch" />          <s:enumeration value="Microns" />          <s:enumeration value="Mils" />          <s:enumeration value="Millimeters" />          <s:enumeration value="Centimeters" />          <s:enumeration value="Inches" />          <s:enumeration value="Links" />          <s:enumeration value="Spans" />          <s:enumeration value="Feet" />          <s:enumeration value="Cubits" />          <s:enumeration value="Varas" />          <s:enumeration value="Yards" />          <s:enumeration value="Meters" />          <s:enumeration value="Fathoms" />          <s:enumeration value="Rods" />          <s:enumeration value="Chains" />          <s:enumeration value="Furlongs" />          <s:enumeration value="Cablelengths" />          <s:enumeration value="Kilometers" />          <s:enumeration value="Miles" />          <s:enumeration value="Nauticalmile" />          <s:enumeration value="League" />          <s:enumeration value="Nauticalleague" />        </s:restriction>      </s:simpleType>      <s:element name="ChangeLengthUnitResponse">        <s:complexType>          <s:sequence>            <s:element minOccurs="1" maxOccurs="1" name="ChangeLengthUnitResult" type="s:double" />          </s:sequence>        </s:complexType>      </s:element>      <s:element name="double" type="s:double" />    </s:schema>  </wsdl:types>  <wsdl:message name="ChangeLengthUnitSoapIn">    <wsdl:part name="parameters" element="tns:ChangeLengthUnit" />  </wsdl:message>  <wsdl:message name="ChangeLengthUnitSoapOut">    <wsdl:part name="parameters" element="tns:ChangeLengthUnitResponse" />  </wsdl:message>  <wsdl:portType name="lengthUnitSoap">    <wsdl:operation name="ChangeLengthUnit">      <wsdl:input message="tns:ChangeLengthUnitSoapIn" />      <wsdl:output message="tns:ChangeLengthUnitSoapOut" />    </wsdl:operation>  </wsdl:portType>  <wsdl:binding name="lengthUnitSoap" type="tns:lengthUnitSoap">    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />    <wsdl:operation name="ChangeLengthUnit">      <soap:operation soapAction="http://www.webserviceX.NET/ChangeLengthUnit" style="document" />      <wsdl:input>        <soap:body use="literal" />      </wsdl:input>      <wsdl:output>        <soap:body use="literal" />      </wsdl:output>    </wsdl:operation>  </wsdl:binding>  <wsdl:binding name="lengthUnitSoap12" type="tns:lengthUnitSoap">    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />    <wsdl:operation name="ChangeLengthUnit">      <soap12:operation soapAction="http://www.webserviceX.NET/ChangeLengthUnit" style="document" />      <wsdl:input>        <soap12:body use="literal" />      </wsdl:input>      <wsdl:output>        <soap12:body use="literal" />      </wsdl:output>    </wsdl:operation>  </wsdl:binding>  <wsdl:service name="lengthUnit">    <wsdl:port name="lengthUnitSoap" binding="tns:lengthUnitSoap">      <soap:address location="http://www.webservicex.net/length.asmx" />    </wsdl:port>    <wsdl:port name="lengthUnitSoap12" binding="tns:lengthUnitSoap12">      <soap12:address location="http://www.webservicex.net/length.asmx" />    </wsdl:port>  </wsdl:service></wsdl:definitions>

 

Creating an ABAP Proxy:

 

After deleting the messages without only one part and the respectively port-types we can import the WSDL file into SAP.

To do so in transaction SE80 select package from the dropdown create or use an existent package to your services and right click it select Create->Enterprise Service:

2.png

A Wizzard will start.

Select Service Consumer an click continue:

3.png

Select Local File and click Continue:

4.png

Select the editted WSDL file and click continue:

5.png

Select Package, Prefix and Request to your Service consumer and click Continue:

6.png

IMPORTANT: The prefix must be started with Z or Y otherwise the SAP will ask for object Keys.

 

Click Complete:

7.png

Our service consumer is now created, but it is still not activated:

8.png

Click the Activate Button 9.png.

 

Sucssess! 10.png

 

 

We're now half way done.

We have our proxy but it still does not works. That's because we have not configured the endpoint of service.

To do so I'll go to transaction SOAMANAGER. (LPCONFIG in older versions) where we'll configure the endpoit of our service.

 

Configuration:

 

Go to transaction SOAMANAGER if everything goes right you'll be redirected to a web browser in the following page (if you were redirected to a login page, just fill your SAP user/password):

11.png

Click in Application and Scenario Communicaton and Single Service Administration:

 

12.png

 

Search for your created proxy (just remember it is a Consumer Proxy):

 

13.png

Tip: you can find both  External and Internal name in tab External View from your proxy:

14.png

Back to our Webservice Administration:

Select your service, click Apply Selection Button and go to Configurations tab:

15.png

Click Create Logical Port Button Fill the port name, Description, Configuration Type and WSDL Base:

(the File with WSDL Document is your modifyed WSDL document that you saved in your computer in the beginning of this post)

16.png

Click Apply Settings and Save:

17.png

Testing:

 

Back in our SAP ERP system we can test the service just by clicking in test tool (F8).

 

Select your Logical Port (just created) and click on execute button:

 

18.png

 

Fill some valid Values:

19.png

 

Click on Execute Button  and check the response:

20.png

 

Calling From ABAP Program:

 

Here is a test program for calling this Proxy:

 

*& Report  ZTEST_PROXY

 REPORT  ZTEST_PROXY.
 * Data Declarations
 DATA: cl_proxy TYPE REF TO ZCO_LENGTH_UNIT_SOAP, " Proxy Class       data_in  TYPE ZCHANGE_LENGTH_UNIT_SOAP_IN, " Proxy Input       data_out TYPE ZCHANGE_LENGTH_UNIT_SOAP_OUT, " Proxy Output       fault    TYPE REF TO cx_root. " Generic Fault

 * Instantiate the proxy class providing the Logical port name
 CREATE OBJECT cl_proxy EXPORTING LOGICAL_PORT_NAME = 'DEFAULT_PORT'. 

 * Set Fixed Values 
 data_in-LENGTH_VALUE = '32'.
 data_in-FROM_LENGTH_UNIT = 'Inches'.
 data_in-TO_LENGTH_UNIT  = 'Millimeters'.

 TRY .
   cl_proxy->CHANGE_LENGTH_UNIT( EXPORTING INPUT = data_in                                 IMPORTING OUTPUT = data_out ).
 CATCH cx_root INTO fault.
 * Here is the place for error handling   BREAK-POINT.
 ENDTRY.
 *  Here the structure data_out is filled case none Exceptions occurs
 BREAK-POINT.

ABAP Language at TechEd 2013 - Rock Your Code with ABAP 7.40!

$
0
0

In workshop CD261 at this years TechEds you will get your hands on expression enabled ABAP 7.40.

 

As almost every year the question arised, what kind of exercise can we offer to you, Two years ago, I prepared a pocket calculator simulation that was written in old style code and that the participants had to refactor to expression oriented code as far as possible with ABAP 7.02. Since gamification is such a buzz word and since another subject of the workshop - ABAP Channels - is also exemplified by a game, we (Holger and myself) have decided to also use a gaming example for expression enabled ABAP this year. We searched for an existing game programmed in ABAP and prepared it in such a way that it is usable for an exercise.

 

 

The existing game

 

As a suitable game we found a Jawbreaker adaption in Enno Wulff's Trick Tresor:  Well, if you look at the code, you see typical ABAP as you can find tons of it in real life programs: full of forms, OCCURS, WRITEs, ... (and comments and names in German) but no offense!. We like the idea of the game but it cannot be an exercise template in such a pre ABAP Objects state .

 

Refactoring the game for ABAP 7.0

 

Theerfore, we have rewritten the game in such a way that it represents a state-of-the-art 7.0 ABAP program. The new version uses ABAP Objects instead of subroutines of course and no other obsole statements any more. And since classical list programming is regarded as a kind of old fashioned, the game interface is realized as an HTML file shown in a browser control (but we will also offer a list based version):

 

blocks.jpg

 

You find the source code of the refactored game attached as Z_BLOCKS_HTML_700.txt. You can copy the code to your 7.02 or 7.0 sytem and run it happily there (since the convenience class CL_ABAP_BROWSER is not yet available in 7.0, you have to replace it with CL_GUI_HTML_VIEWER and use an own custom control there).  But the game is not the aim.

 

 

Express the game in 7.40

 

The aim is to beautify the ABAP code by replacing statements and helper variables with expressions whilst the functionality stays the same. This will be an exercise of the 2013 TechEd workshop. I could attach the full solution right now, but I won't (no cheating!). All I will say is that you can reduce the amount of lines by 35% by introducing expressions as shown in the following code snippets:

 

Example 1

 

Z_BLOCKS_HTML_700

 

DATA:
  rnd_color TYPE REF TO cl_abap_random_int,
  seed TYPE i.

seed = sy-uzeit.
rnd_color = cl_abap_random_int=>create( seed = seed min = 1 max = 4 ).

 

Z_BLOCKS_HTML_740

 

DATA(rnd_color) =
  cl_abap_random_int=>create( seed = CONV i( sy-uzeit ) min = 1 max = 4 ).

 

Example 2

 

Z_BLOCKS_HTML_700

 

READ TABLE field INDEX x ASSIGNING <column>.

READ TABLE <column> INDEX y ASSIGNING <color>.

 

Z_BLOCKS_HTML_740

 

DATA(color) = field[ x ][ y ].

 

Example 3

 

Z_BLOCKS_HTML_700

 

CASE <color>.

  WHEN 1.

    color = `lightblue`.

  WHEN 2.

    color = `cornflowerblue`.

  WHEN 3.

    color = `darkblue`.

  WHEN 4.

    color = `steelblue`.

ENDCASE.

DATA:

  xn TYPE n2,

  yn TYPE n2.

xn = x.

yn = y.

CONCATENATE

  html

  `<td bgcolor="` color `">`

  `<a href="sapevent:x` xn `y` yn

  `" style="text-decoration:none">` square `</a></td>`

INTO html.

 

Z_BLOCKS_HTML_740

 

html =

  html &&

  |<td bgcolor="{ SWITCH string( color  WHEN 1 THEN `lightblue`

                                        WHEN 2 THEN `cornflowerblue`

                                        WHEN 3 THEN `darkblue`

                                        WHEN 4 THEN `steelblue`) }">| &&

  |<a href="sapevent:x{ CONV n2( x )

                    }y{ CONV n2( y )

                    }" style="text-decoration:none">{ square }</a></td>|.

 

 

 

And of course, you can get your hands on ADT (Eclipse) for rewriting the code ...

 

See you at TechEd!


ABAP Security at TechEd 2013 - Scan, Analyze, and Fix Your Programs!

$
0
0

In workshop SIS261 at this years TechEds you will learn about possible vulnerabilities in ABAP code and you will also learn a new way of finding and fixing them.

 

 

ABAP and Security

 

Security issues in ABAP?  Isn't that handled by SAP, so nothing to worry about as an ABAP developer? Unfortunately this is not the case. As pointed out in a blogand more detailed in the documentation code injections and insufficient authority checks can become serious security risks also in ABAP programs. The following code snippet shows a prominent example:

 

DATA customers TYPE TABLE OF scustom WITH EMPTY KEY.

 

DATA name TYPE string.
cl_demo_input=>request( CHANGING field = name ).

 

DATA(cond) = `country = 'DE' AND name = '` && name && `'`.

TRY.
    SELECT * FROM scustom
             INTO TABLE customers
             WHERE (cond).
    cl_demo_output=>display( customers ).
  CATCH cx_sy_dynamic_osql_syntax.
    cl_demo_output=>display( 'Wrong input' ).
ENDTRY.

 

A field name that is delivered from the outside of a program is directly concatenated into a dynamic token of Open SQL.The vulnerability is a potential SQL Injection. If "x' OR name <> '" is entered for name, all the data from the SCUSTOM table is displayed.

 

 

Fixing Programs

 

The workshop will show you ways how to fix your programs. In the above example you can replace

 

DATA(cond) = `country = 'DE' AND name = '` && name && `'`.

 

with

 

DATA(cond) = `country = 'DE' AND name = '` &&

             cl_abap_dyn_prg=>escape_quotes( name ) && `'`.

 

to prevent a potential SQL Injection.

 

But how to find potential security risks?

 

 

Scanning and Analyzing programs

  

With Releases 7.0, EhP2, SP14, Release 7.3, EhP1, SP09 and Release 7.40, SP05 SAP plans to deliver a SAP NetWeaver Application Server, add-on for code vulnerability analysis that can be purchased as a separate product. This tool will be embedded in the well known Extended Program Check (SLIN) and herewith in the ABAP Test Cockpit (ATC) that also becomes available for customers.

 

slin_sec.jpg

These Security Tests carry out a static data flow analysis and will find such vulnerabilities as shown above.

slin_sec.jpg

slin_sec.jpg

 

The integration into ATC looks as follows:

slin_sec.jpg

 

slin_sec.jpg

 

Checks can be carried out during development and findings can be analyzed by the developer. Each message is accompanied by a long text with further information that points out how to fix a problem.

 

slin_sec.jpg

 

You can setup your system in such a way that transports cannot be realeased as long as security risks are found in programs to be transported.

 

Want to learn more?  Hope to see you at TechEd in workshop SIS261!

 

 

 

 

 

 

 

 

 

 

Handy SAP function module to automate user inputs

$
0
0

Let me start my first blog with a useful function module that I came to know while solving one of the commonly faced issues in SAP(ABAP).

 

MESSAGE 'Text' TYPE 'E'.

On execution of this statement,processing stops,screen input field(s) gets disabled and the poor end-user has to press ENTER key to input again the screen input values. During my initial days as an ABAPer,I was not aware of the useful message_options of the MESSAGE statement (DISPLAY LIKE 'W' and 'E'). So I googled without any hope to find out if there is any way that I could automate the event of user pressing the ENTER key.Wow! I got one.Made me wonder whether there is anything that ABAP doesn't provide. ABAP is too good!!!!!

 

*Begin-Auto triggers ENTER command

 

     CALLFUNCTION'SAPGUI_SET_FUNCTIONCODE'

       EXPORTING

            functioncode           ='ENTER'

       EXCEPTIONS

            function_not_supported =1

            OTHERS                    =2.

*End-Auto triggers ENTER command


SIMILARLY YOU CAN WORK AROUND WITH OTHER STANDARD AND CUSTOM FUNCTION CODE VALUES (viz.,SAVE,EXECUTE etc.) THAT NEEDS AUTO-TRIGGER.

 

Cheers,

-K.ArunPrabhu

Blog It Forward : Mohammed Yakub Shah

$
0
0

My SCN mate.... that is a social site too now huh.....

 

Arindam Mondal asked me to join the 'Blog it forward' challenge.... and how can you turn down such a request.

 

Thank you for giving this opportunity to me Arindham...

 

Well here goes nothing.

 

Name is  'Mohammed Yakub Shah'  and am a Principal Consultant at SEAL Infotech Pvt. Ltd. I am into SAP Technical since 10 years now and still have a new thing to learn every single day.

 

Thats me at a project in Delhi.....

 

me.jpg

 

I am married and have 1 son and very very very cute....

IMAG0063.jpg

I love to watch cartoons [still a kid at heart I suppose] and the experience is unmatchable when you do it with you kid...

 

Playing Video games is another hobby of the Duo specially like Prince of Persia, God of War... makes my wife go crazy... but can't help

 

My City : Mumbai

 

Born and brought up here it is one of the most lively place on earth..... don't have words to express it ... I won't even try.

 

mumbai.png

mumbai01.png

 

Now for the questions :

 

1) What are the best experiences that you had while being part of this community?

 

Well the BIF adds to the best experience .... You get to learn new things every moment here and get to know people you wouldn't have know....

 

Most queries make you  scratch your brain and really think in the other persons shoe.... makes you SMARTER I suppose.

 

2) What are the hobbies or activities that you enjoy most?

 

Well I guess I answered this already Playing Video Games...... and Cricket if time pemits very rare being a consultant

 

In keeping the BIF going, I am asking the following questions:

 

  1. What would you be if not an SAP Consultant ?
  2. What was the most fun project you ever participated in and why?

 

Friends please answer the call

 

Jason Lax

Matthew Billingham

Susmitha Susan Thomas

 

And finally Raymond Giuseppi

 

Thanks.

Missing Comments and Documentation.. a bit like global warming

$
0
0

Thought of writing the blog the share the most common issue after a SAP maintenance project is handed over or when new consultants come into the project. The first few days there are high level descriptions/discussions of what's there in the landscape and what not. Then comes the hard part when bugs or tickets or incidents starts coming in. Then the effort taken often to understand the process is often painstaking due to lack of code comments or documentation(In code and as specifications) and usually ends up taking  more time compared to what might have been used if it was done in the first place

 

Little comments in the code if they are missing often don't reap the benefits immediately but always help in the long run. The missing comments are like small amounts of C02 that eventually causes water levels to rise and thus flooding or temperature swings..(when you manager is chasing you solve an incident or an issue and you don't have enough time to dig through the layers of custom code and hope that some documentation or comments would have helped)  and the effort to do it later is much more effort-intensive.

 

Now people might think what it has to do with say I create 1 Z-Report or 1-Function module or Just activate a BADI and write a small snippet of code. But in the long run artifacts or objects gets added over the years, remember business that use Z-process would not change often and keep doing even more customizations. I had the experience of working with such clients. They install SAP and then create Z-Transactions to fit in business requirement, might sound crazy and stubborn but the logic often given is I want my business to run my way not always the way what SAP says( suits them as they are one of the BIG 5 consulting firms ).

 

The other thing is now we get many versions of SAP modules and categories and often many scenarios and modules and processes and business practices are not always accounted for in standard SAP packages or often come later after SAP starts delivering it for such and industry. Such things are validated by the various solutions SAP has delivered from time to time. Like access of SAP clients shifted from Desktop client in its early years to web-based and now moving to cloud based to many new modules introduced over years to get into various industry segments.

 

Now how can small comments help in the log run..

 

Well the small comment that you write and may be leave the project will always help the other consultant coming in and trying to do some changes or add on code or comment out logic. I know the other aspect is people will say what about requirements and design documents. Well they are often done in a bare minimum way and often its not there. Another scenario is often say an age old documentation of a report of Module pool screens exist but the programs might have changed several times over years and the initial logic parts might have changed or many new features might have been added and that's not there in the documents. Such things often take more time as the developer has to understand the feature and then do any further changes.

 

The other most common scenario is copying BAPI or Standard FM's and then not doing any documentation. Specially with lots of flag fields and generic structures. If large code blocks and nested Z-objects are there they often raise the efforts to understand the code( I remember the days without the new editor and debugger ) .

 

Imagine how bad the demo programs will be provided by SAP, had they missed out on the comments I am sure few runs and debug would be required to know what's happening.

 

Often small comments and documentation set the pitch for quick understanding improves code readability and thus improving maintainability. Remember when you clicked the documentation button and it said only available in DE and then translated then via translation tools or sites in internet.

 

With the future going OOPS. Its good to have class and methods commented and documented as they are complex objects and say a Z-class with Z-methods if not documented can be hard on people following up with changes or additions to the same. Basic comments or on use of class and methods will always help.

 

So small missing documentation or comments can make a simple custom development look apparently complex. If present and done on the time development or changes are done can save a lot of effort for future and help improve code readability and maintenance.

 

So, follow the rule of always commenting or documenting even though it looks useless its good in long run. So ending this blog with few links on documentation.

 

http://help.sap.com/saphelp_40b/helpdata/EN/c8/19764e43b111d1896f0000e8322d00/content.htm

 

http://help.sap.com/saphelp_nw04s/helpdata/en/cf/fa40424319b16be10000000a155106/content.htm

 

http://help.sap.com/saphelp_erp60_sp/helpdata/en/43/b46c4853c111d395fa00a0c94260a5/content.htm

 

Cheers,

Arindam

Thoughts on OO Events Mechanism

$
0
0

Object oriented Events in ABAP

 

As i was moving into object oriented world ı come across with the concept EVENTS

 

Why Events?

 

Well, something important has happened

 

Someone needs to know!!

 

 

I started looking at the events, which was understandable but not really!!

There is a channel where there is the

  • publishers
  • subscribers

 

Publishers are the ones that raise the event or expose the event.

Subscribers are the ones that are interested in these events.

 

When i look at the examples they all give similar examples mostly on the Gui side of the things.

Events make more sense in the user interface at the end

Where as it makes more sense as the application get bigger and bigger

 

Before events in oo world there was Business Transaction Events that i get to know.

so there was events in that sense before

 

For e.g. Class CL_GUI_ALV_GRID for ALV Grid has published event like USER_COMMAND, DOUBLE_CLICK and ONDRAG etc which could be used by other objects (programs to subscribe and use).

 

How do we use Events in Our Apps

 

We need to decide whether we need events in our applications.

 

Define: is there an important news that involves some objects to know( coupling)

 

If the answer is yes and you are enthusiastic

 

Apply the events in your objects!!

 

 

Scenario:  i  am going to use a scenario here, lets say we have an application of  editors like word, excel

And the user is using these tools to create documents.

So we have word application excel application etc...

 

Document creation is going to be our main event!!

 

in my opinion better that all the events are exposed through interfaces!!

important:The full code is attached as a zip file you can see the other object like lcl_document below!!

 

 

Step 1 -- Define the publisher interface ( events are here)

 

in Code:

 

**Publisher

interface lif_event.

   EVENTS: document_created.

ENDINTERFACE.

 

Step 2- Define the Listener interface( who needs to know)

***Listener

INTERFACE lif_listener.

   METHODs: on_document_created FOR EVENT document_created

   of lif_event.

ENDINTERFACE.

 

Step 3 - Then comes to play the event publishers that implement the publishing interface.

All the listeners are registered through the interface

 

 

class lcl_word_app DEFINITION.

   PUBLIC SECTION.

     INTERFACES lif_publisher.

methods: create_document EXPORTING eo_document TYPE REF TO lcl_document.

ENDCLASS.

 

 

class lcl_excel_app DEFINITION.

   PUBLIC SECTION.

     INTERFACEs lif_publisher.

methods: create_document EXPORTING eo_document TYPE REF TO lcl_document.

ENDCLASS.

 

Step 4- Event listeners who are interested in the events

 

******Listeners go here!!!!!!

 

class lcl_listener_1 DEFINITION FINAL.

   PUBLIC SECTION.

     INTERFACES lif_listener.

     ALIASES on_document_created for lif_listener~on_document_created.

 

ENDCLASS.

 

 

class lcl_listener_2 DEFINITION FINAL.

   PUBLIC SECTION.

     INTERFACES lif_listener.

     ALIASES on_document_created for lif_listener~on_document_created.

 

ENDCLASS.

 

Last Steps of course:

 

***** is the User

class lcl_user DEFINITION.

   PUBLIC SECTION.

     class-data: lcl_word_app TYPE REF TO lcl_word_app,

                 lcl_excel_app  TYPE REF TO lcl_excel_app.

 

     CLASS-METHODS: class_constructor.

 

     METHODS: raise_word_event.

     METHODS: raise_excel_event.

ENDCLASS.

 

 

You can see the full code in the report z_test_events

 

 

I hope it was clear and you find it useful!!

 

Please comment on anything

Viewing all 948 articles
Browse latest View live


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