Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all 943 articles
Browse latest View live

Excited to do some sleuthing!

$
0
0

Getting IP ADDRESS IN SAP

 

Bliss! Never thought my secret desires during childhood days, of being a sleuth, like my heroes in detective novels, could find some gratification if I pursued a career in IT!

 

Alright! Alright! I know there is an entire wing in IT dealing with information security and that this is not something alien in IT. But come on! This is my first experience in this area, (other than the authorization checks being done for every transaction) and I have every reason to feel excited about it! 

 

Yep! Got a requirement that if anyone tries to manipulate any sensitive  information like basic pay info type or bank account info type, system should log the action with the username in SAP with which he has logged in, and the IP Address() of the computer that he was using for the purpose. (Well user name seemed fine, but IP Address! From SAP!  Woah! Thought that would be a load of work.) And, also, immediately send a mail to manager informing him such an attempt was made, with all the details.

 

Well, it turned out that getting the IP Address from SAP was a piece of cake.

 

There are various function modules and class methods in SAP for doing this, and the one which I used was the following.

 

data lv_ip(30) typec


callmethod cl_gui_frontend_services=>get_ip_address
receiving
ip_address           = lv_ip
exceptions
cntl_error           =
1
error_no_gui         =
2
not_supported_by_gui =
3
others               = 4.

 

if sy-subrc <> 0.
messageid sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

 

And the icing on the cake – Manager is totally happy with the output!

 

By the way, if anybody feels that there are loop holes in this function, do let me know. I want to be sure that when I do something such as this; it is totally fool-proof!

 

So to sum up! Being in IT, and in SAP, I can contribute to the interests of CIA!  Ahem! Not Central Intelligence Agency: Confidentiality, Integrity and Availability.

 



ABAP News for Release 7.40

$
0
0

This blog summarizes a series of blogs that I have written about the most important ABAP News for Release 7.40 during the last few month.

 

Getting Started

 

First you might be interested in

 

What is ABAP 7.40?

 

Then you can

 

Warm up with Expressions.

 

 

ABAP News by Subject

 

Have a more detailed look at

 

 

After all of this, surely it is time to say bye, bye to MOVE and COMPUTE ...

 

 

Learn More

 

Lookup the News in the ABAP Keyword Documentation.

 

Come to CD261 at TechEd 2013!

 

There is also a slide deck around somewhere.

Wonders in ABAP Editor se38

$
0
0

I was wondering in ABAP editor se38.

See the below screen shots,

1.PNG

 

2.PNG

From the above screen shots the  program name's are different while checking it is not throwing any syntax error.

 

As well As i didn't pass any report name like below screen shots, but it did not throw any syntax error.

 

3.PNG

I gave the following report name which i already created ZRTEST_REP_KEY1 then i want find the program using the where used list it throws the below error screen shot.

 

4.PNG

Using SUBMIT key i submitted that report into my report. Then i clicked the where used list it does display like the below screen shot.

 

5.PNG

 

6.PNG

And also i created one subroutine which met all the above first three screen shots behavior.

 

7.PNG

 

As well as i created  one more include program it is also met the same.

 

8.PNG

What ever it may be the ABAP editor will not consider any thing on report first it will search the program has the key word report or program if not it will leave the syntax error otherwise it will read the program from the repository through the program attributes.

ACCOUNTTAX in BAPI_ACC_DOCUMENT_POST

$
0
0

After poring over SDN for hours together, I discovered that there was no one document which detailed the posting of FI Documents with Tax lines. This post is an endeavour to make it easier for other looking for the similar content.

 

While posting FI documents, for example vendor invoices in FB60. We have an option of posting tax amount and doing this via ABAP via the BAPI_ACC_DOCUMENT_POST/BAPI_ACC_DOCUMENT_CHECK has proven to be tricky in my experience.

 

This post will primarily deal with vendor invoices and will be used to detail the posting of tax data via BAPI_ACC_DOCUMENT_POST/BAPI_ACC_DOCUMENT_CHECK

 

The Tax Data can be seen for the relevant documents via the transaction FB03

 

FB03.jpg

FB03-1.jpg

FB03 - 2.jpg

The post will detail the posting of tax data with the Tax Code T1 and Tax Jurisdiction TJ000000 as shown above

 

The DOCUMENTHEADER, ACCOUNTGL, ACCOUNTPAYABLE and CURRENCY AMOUNT will be populated as per the normal processing of the BAPI_ACC_DOCUMENT_CHECK/POST

 

The file that has been attached has been used as an example to detail the scenario.

 

The DOCUMENTHEADER will contain the following details:

 

FieldValue
USERNAME                                  SY-UNAME
HEADER_TXT                                  *AP UPLOAD CREDIT
COMP_CODE                                  1001
DOC_DATE                                  20130102
PSTNG_DATE                                  20130708
TRANS_DATE                                  00000000
FISC_YEAR                                  2013
FIS_PERIOD                                  00
DOC_TYPE                                  KR
REF_DOC_NO                                  CREDIT-8

 

DOCUMENTHEADER.jpg

 

The ACCOUNTGL contains

 

FieldValue
ITEMNO_ACC

0000000002 

GL_ACCOUNT

0000677000 

ITEM_TEXTNew fields 4
COMP_CODE1008
TAX_CODEI1
TAXJURCODETJ000000
COSTCENTER10013

 

ACCOUNTGL.jpg

The ACCOUNTPAYABLE contains

ACCOUNTPAYABLE.jpg

The CURRENCYAMOUNT would, in the normal scenario, have only 2 items containing the vendor and account payable amount information. As you might already know, this table contains all the currency amounts relating to the document. In a normal financial document without any tax data, the table GT_CURRENCYAMOUNT would contain the following

 

CURRENCYAMOUNT_No Tax.jpg

 

Since our document contains tax data, we need to populate the ACCOUNTTAX table which is used exclusively to populate the tax data and we also need to populate a dummy line item in the CURRENCYAMOUNT internal table with both the ITEMNO_ACC being the same. In this case, the ITEMNO_ACC would be '0000000003' and the CURRENCYAMOUNT table would be updated with the third line item containing the

 

  • ITEMNO_ACC
  • CURRENCY
  • AMT_DOCCUR
  • TAX_AMT
  • AMT_BASE

 

shown as follows

 

CURRENCYAMOUNT_Tax.jpg

 

In ACCOUNTTAX, a record containing the

  • ITEMNO_ACC
  • GL_ACCOUNT
  • COND_KEY
  • ACCT_KEY
  • TAX_CODE
  • TAXJURCODE

 

are populated. As shown below:

 

ACCOUNTTAX.jpg

 

 

In the current scenario, the tax code and tax jurisdiction is provided by the user. Based on which the COND_KEY and ACCT_KEY are decided using the function module 'CALCULATE_TAX_FROM_NET_AMOUNT' In this case, user had provided us with the tax amount and the base amount, but if the tax amount is not provided, various function modules can be used to calculate the tax based on the base amount.

 

The common error that is encountered while posting tax data is 'FI/CO interface: Balance in transaction currency' This comes up if the amounts in the table CURRENCYAMOUNT-AMT_DOCCUR do not balance. ABAPers need to make sure that the amounts balance exactly as shown below

 

CURRENCYAMOUNT_Balance.jpg

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 .

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 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 ), and the other 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 an 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 PAI events

$
0
0

Let me start my first blog with a handy 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.

Viewing all 943 articles
Browse latest View live


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