Category Archives: ABAP

Прокси-сервер в ABAP

Если вы из программы на ABAP пытаетесь получить веб-контент через HTTP, то соединение будет производиться не с компьютера клиента, а с сервера приложений. В зависимости от конфигурации локальной сети вам может понадобиться пробираться через прокси-сервер (иначе потребуется прямая видимость сервера или NAT).

При оформлении HTTP запроса можно непосредственно указать прокси-сервер:

Однако здесь есть пара моментов. Во-первых – хардкод в коде не приветствуется, а во-вторых – нет авторизации.

Глобальную настройку HTTP-прокси можно обнаружить в транзакции SM59:

И там уже в появившемся окошечке можно указать не только сервер/порт, но также и логин/пароль для авторизации.

© Иван Болховитинов

Важные слова не важны

В процессе написания кода по заданной спецификации неожижанно обнаружилось, что ключевые слова ABAP не являюся зарезервированными.
Поэтому нижеследующий код компилируется и даже выполняется:

Даже если так писать и можно, то этого делать всё-таки не следует:

  • Усложняет восприятие, хотя есть и подсветка кода и uppercase/lowercase
  • Name-conventions
  • Ограничения при работе с БД
  • Это не смешно

Зато есть служебная таблица TRESE, в которой перечисляются разные наименования полей, которые нельзя создавать из-за ограниченний в разных БД.
© Иван Болховитинов

IDoc statuses

IDoc Inbound and Outbound statuses
Table TEDS1 contains list of all status codes.
Starting statuses may be: 01 (outbound), 50 (inbound), 42 (outbound test), 74 (inbound test)

St#
OK / NOK
Description Next success status Next error status Error reason and solution
01 Outbound IDoc created 30 29
02 Error passing data to port Correct the error and Execute RSEOUT00 program again
03 Outbound IDoc successfully sent to port None, 32
04 within control information on EDI subsystem
05 during translation
12 Dispatch OK Changed from status 03 by BD75 transaction (see below)
25 Processing outbound IDoc despite syntax errors
26 during syntax check of outbound IDoc Missing mandatory segment for example You may edit the IDoc or force it to be processed
29 ALE service (for example 29, 31
30 Outbound IDoc ready for dispatch (ALE service) 03 02 Partner profile customized to not run and execute RSEOUT00 program
31 no further processing
32 Outbound IDoc was edited There was a manual update of the IDoc in SAP tables, the original was saved to a new IDoc with status 33
33 Original of an IDoc which was edited. It is not possible to post this IDoc None None Backup of another IDoc manually updated, see status 32
35 IDoc reloaded from archive. Can’t be processed
37 Erroneous control record (for example, “reference” field should be blank for outbound IDocs) None, 37
42 Outbound IDoc manually created by WE19 test tool 01 37
50 Inbound IDoc created 64 65
51 inbound IDoc data contains errors 53, 64 51, 66, 68, 69 Error triggered by SAP application, incorrect values in the IDoc data and ask functional people, modify erroneous values in the IDoc (WE02 for example) and run it again using BD87
53 inbound IDoc posted None, 53
56 IDoc with errors added (You should never see this error code) 50, 51, 56, 62, 68
60 syntax check of inbound IDoc 56, 61, 62
61 Processing inbound IDoc despite syntax error 64
62 inbound IDoc passed to application 53 51
63 passing IDoc to application
64 Inbound IDoc ready to be passed to application 62 51, 60, 63, 68, 69  execute BD20 transaction (RBDAPP01 program)
65 ALE service – incorrect partner profiles 64, 65
66 Waiting for predecessor IDoc (Serialization) 51
68 no further processing 68 None The IDoc was created using inbound test tool (WE19) and written to file to do file inbound test. Another IDoc is created if immediate processing is chosen
69 IDoc was edited 64 51, 68, 69 There was a manual update of the IDoc in SAP tables, the original was saved to a new IDoc with status 70
70 Original of an IDoc which was edited. It is not possible to post this IDoc None None Backup of another IDoc manually updated, see status 69
71 Inbound IDoc reloaded from archive. Can’t be processed
74 Inbound IDoc manually created by WE19 test tool 50, 56

More information about Inbound statuses

  • 64 -> 62: There is no way to distinguish automatic call from manual call (BD20, RBDAPP01)
  • Though an IDoc may contain partner profile errors, we may force inbound processing (status becomes 62), but then an error will happen again
  • RSEINB00 program to process IDocs from a file
  • BD20 transaction (RBDAPP01 program) to process IDocs in status 64. If you want future IDocs to be processed immediately, change partner profile customizing (WE20).
  • RBDINPUT program:
    • status 51: BD73 / RBDMANIN
    • Status 56, 61, 63, 65: BD84 / RBDAGAI2
    • status 60: RBDSYNEI
    • status 62: IDocs remaining in status 62 is abnormal. Use program RBDCHSTA (Note 92552 – IDocs-Status 62 cannot be processed), so that to change their status back to 64 and process them again
    • status 64, 66: BD20 / RBDAPP01
    • status 68: WPIE / RBDAGAIE

More information about Outbound statuses

  • RBDOUTPU program:
  • status 02, 04, 05, 25, 29: BD83 / RBDAGAIN
  • status 26: RBDSYNEO
  • status 30: WE14 / RSEOUT00
  • status 32: WPIE / RBDAGAIE
  • -> 03 : IDocs are sent to the tRFC queue.
  • 03 -> 12 : use BD75 transaction (RBDMOIND program). Idocs with with status 03 are transferred to the tRFC queue. This does not mean that they are sent out, they may stuck up on that queue (e.g. receiver system is down) in that queue. BD75 checks if it can find the idoc in that queue. If so, it is not beeing send and status remains on 03. If it is not on the t-rfc queue, the systems considers that this icon is sent and change the status to 12.
    You can check the tRfc queue with SM58 and initiate resending by right click choosing execute LUW.
    in BD75 you can check “unsent idocs” and you will get a similar list.

  • Note 189887 – ALE: Help report to search for IDocs sent twice: program ZDUPLICATEIDOC

Miscellaneous

  • RC1_IDOC_SET_STATUS program to change IDoc status. Exists since 6.10
  • Monitor for Inbound and Outbound: BD87 / RBDMON00 to restart erroneous IDocs
  • Archiving:
    • RSEXARCA archives IDocs. They must be in an archivable status (not possible to archive IDocs in status 30 or 64, ie waiting to be processed).
    • RSEXARCL to reload IDocs from archive to the database. Status will be either 35 (outbound) or 71 (inbound).
    • WE47 to change STACUST table; see Note 26564 – IDoc: Can status values be defined?
  • RSECSTAT include contains constants for status

ZTOAD – alternate SQL builder (SAPLink)

ZTOAD – is an alternate SQL builder (SAPLink). It can be installed using SAPLink (SAPLink should be installed as well).

SAPLink is a tool for importing and exporting ABAP developments from one system to another. The main terms of SAPLink are nuggets and slinkies:
a) a slinkee file (.slnk) is used for single objects to be imported or exported. Slinkees are very quick and easy to use and recommended for single object collaboration. They can be imported and exported from the “Object” tab.
b) SAPLink nuggets are the SAPLink packaging system that enables multiple objects to be imported/exported in one handy dandy file (.nugg). Nuggets can be imported, created, and displayed from the “Nugget” tab.

With ZTOAD (called ZTOAD in reference of a famous query builder in the SQL) you can write and execute queries, in OpenSQL format (the format used in ABAP programs). Result is displayed in an ALV at bottom part of the screen:

The order is next:
1. Install SAPLink
2. Install DDic plugin (just import NUGG_SAPLINK_DDIC.nugg nugget file).
3. Install ZTOAD
4. Launch SE38 -> ZTOAD

P.S. In case of error “CLASS ZSAPLINK DEFINITION LOAD statement is missing.” just add the string

after the string

in the ZSAPLINK program.

P.P.S. “Plugin for object type TRAN is not installed on this system”: CLAS_ZSAPLINK_TRANSACTIONS.slnk,
“Plugin for object type DEVC is not installed on this system”: CLAS_ZSAPLINK_DEVC.slnk
and activate “Inactive local objects” in SE80.

Smart Forms vs Adobe PDF-based forms

Here is a comparison between the two largest print form formats.
All new forms delivered with the ERP will be PDF-based. So, it’s probably better to get ready to change.

Knowing those two print forms possibilities offered by SAP, you want to know more about what is the best technology to use.

Hopefully I’ll provide you some answers in this paper. I’ll probably write more complete comparisons as experiences with PDF forms grows.

Smart Forms architecture

The application program retrieves data from the database and is passed to the function module generated by the Smart Form. The application program, which collects data, has to be written. In many cases, a standard print program is copied, modified and then reused.

The Smart Form needs to be defined. With transaction SMARTFORMS, you can setup the layout you want. This is a powerful but quite old tool and its usage is requires some learning time.

PDF-based print forms architecture

At runtime, we notice the architecture is very close of the previous one.

In this case, a print program also needs to be written. The PDF form template, consuming data from its interface, is called by the generated function module. The call to the web service and the PDF is physically built during runtime.

The ADS component runs on the J2EE stack and exposes a web service allowing the rendering of PDF forms. This means extra calls between both stacks.

Note that you can use this web service to build other PDF forms.

Comparison: pro et contra

Development

Every form has layout problems at some point in time. Text is too low the page; the first name is not aligned with the last name, tables don’t display correctly etc. In both cases, there are a lot of tests (“chipotages”, for the French-speaking people) to perform before a form version can be released.

There is a first advantage of PDF in comparison with Smart Forms. The Adobe LiveCycle Designer (ALD) is at first sight simple, yet powerful and comprehensive. So to build a layout is easier with PDF forms for people with limited experience.

When you have lots of forms to develop, you can enhance the custom objects in the ALD: you can add multiple UI objects and group them in one element which you can easily reuse. For instance, a ‘UserData’ element that contains firstname, lastname, street, postal code and city. Element types as well as the layout are stored locally (in folder C:\Users\\AppData\Adobe\Designer\en\objects\), so exchange with other forms developers is quick and easy.

So, bottom line is that development time can be reduced by using PDF forms. Of course, this also depends on your developers’ skills.

Performance

As you know, every object-oriented language has performance problems. So does Java… The ADS component is also heavy and the rendering time of a very complex PDF form, with lots of scripting logic and data to display, can take some time. This may result in heavy documents. Another reason for the sometimes slow performance is the web service connection.

This performance issue must be taken into account when considering high volume printing and complex forms.

Of course, be aware there are possibilities to improve PDF rendering time. Form bundling is one of them (the bundling principle is to send multiple forms in one call to ADS); another one, valid as of NetWeaver 2004s SP12, is described in SAP Note 993612.

Smart Forms, which run fully on the ABAP side, can be faster than PDF… for the moment. I’ll probably post more about performance comparisons in the future.

Regarding stability, both technologies are equivalent and I personally never had problems regarding this. Feel free to provide your input!

Architecture

As said earlier, PDF requires a J2EE stack with ADS properly configured and with connections between both systems up and running. This is done in standard as of NetWeaver 2004 SR1 so don’t panic! Every recent SAP solution includes the J2EE stack including ADS.

There are web services calls between the ABAP and J2EE stacks, which makes for additional connections to handle.

In terms of architecture, the PDF seems to require more attention. Although, the J2EE stack with ADS is installed and configured in standard as of the ERP2004 so there should be no particular worries about this.

Front-end and clients

The PDF requires Adobe Reader to display PDF forms. Nowadays, almost every workstation has Adobe Reader installed on it. Reader is not required to print forms: hopefully, the normal PDF drivers are supported in SAP systems as well as most of standard printer drivers.

Smart Forms require no additional installations on top of the standard SAPGUI.

Compatibility

Customer examples

In this case, everything depends on your scenarios. Some examples for PDF: you need to respect a legal template, which is provided in PDF; PDF is already widely used in your company; you have all the other Adobe products; you need to send printed invoices to your customers automatically via mail with PDF format etc.

On the other hand, you can choose to use Smart Forms for various reasons: your SAP system printing documents is R/3 4.7; you have plenty of qualified developers who know Smart Forms very well; you need very high performance rather than flexibility etc.

Courses

One reference course for Smart Forms: BC470 – Form printing with SmartForms.

The Adobe LiveCycle Designer embedded in an SAP environment offers a lot of possibilities. More information can be found in SAP course BC480 – PDF based print forms (3 days).

Conclusion

Smart Forms is the faithful technology for those who know it. Still useful and reliable as well as very powerful.

On the other hand, the PDF-based print forms is highly appreciated for its comprehensiveness, compatibility, design possibilities. It’s also the future for form output in SAP solutions.

So, the choice is now yours. Personally (but as you may know, I’m not the most objective person when speaking about forms), my choice goes to the PDF for the reasons mentioned above.

© Francois Gendebien

ABAP programming tips

  • Q: How to convert CHAR type to RAW type?
    A:
  • Q: What does mean asterisk in front of the name?
    A: EKPO and *EKPO are usually defined in TABLES statement, and both use the DDIC structure of EKPO. Classical usage is to distinguish between old and new value of the record.
    SELECT SINGLE * FROM *bkpf is equal to SELECT SINGLE * FROM bkpf into *bkpf
    the same as SELECT SINGLE * FROM bkpf is equal to SELECT SINGLE * FROM bkpf into bkpf
  • While declaring variables, always follow the naming conventions through out your code. Your variable names talks a lot about its usage.
    Make sure your variables are of the form:

    {Prefix1}{Prefix2}_{Name} where:

    Prefix1:
    L – Local
    I – Import
    E – Export
    G – Global
    T – Table Type

    Prefix2:
    V – Single Value
    S – Structure
    T – Table
    R – Type ref to Data
    O – Type ref to Object
    E – Type ref to Exception objects

    Name – name of the variable.
    e.g.:
    lt_sel – local table
    lo_rvs – local object
    and so on.

    Before changing the parameters (type or name), make sure that you run “Where used”, make a note and change them as well.
    While working on ABAP Classes and Interfaces, Never change a super class of a framework. It could potentially bring all applications down. Double check to make sure that the code you change is in your class only.

    Ctrl + D Duplicate any line.
    Ctrl + . & Ctrl + , Comment and Un-Comment selected lines.
    Ctrl+Shift+X Deletes the whole line.
    Ctrl+Shift+V Gives All Paste options.
    To assist in locating codes, can be a bookmark, using a combination: CTRL + ALT + (0 to 9).
    To go to bookmark created, use combination CTRL + (0 to 9).

    _sap

    • Please ensure that IV_UNAME (SY-UNAME) and IV_LANGUAGE (SY_UNAME) are mandatory for all modules.
    • Q: How to debug IDOCs inbound processing (most first FMs on receiver system (under ALEREMOTE non dialog user)?
      A: Simple and stupid solution is to put eternal loop in form FA5_DOCUMENT_SYNTAX_CHECK (program LEDI1FA5):

      Then the process will be available for debugging in the transaction SM50.
    • Please create lock objects on the header tables and make sure that you obtain a lock before changes and release the lock after changes.
    • Make sure that you transactions are atomic. Either commit your work after all changes are successful or Rollback in case of error. If you rollback, make sure that you have released the locks.
    • Q: How to pass dynamic varable into SELECT … WHERE IN clause?
      A:
    • During save, please make sure that entries in all the text (_T_*) tables that relate to your modules are also saved. If no data exists, treat it as an error. (As across check, you can verify the same by executing the view and making sure that the data is returned correctly)
    • The Function should be RFC Enabled. Never raise an exception. Always return errors in the ET_RETURN (Type BAPIRET2) structure.
    • Never hardcode text strings. Make sure that you use a text element. But use it with text reference.
      E.g. If you have an error during validating the email, use it as “Email ID is required”(001) instead of using text-001. This will ensure that error messages are displayed regardless of user logon language.
    • At the end of the function, Always call “get details” and return the values as export/table values. This will serve the purpose of reflecting the data as-is in the DB back to the user and will save another round trip to retrieve it again.
    • Q: How to get variable value from another running program?
      A:
    • Update audit fields created by, created date, created time only during create.
    • Please ensure that IV_UNAME (SY-UNAME) and IV_LANGUAGE (SY_UNAME) are mandatory for all modules. Extract the data for the language specified.
    • Q: Where are the packing handling units data stored during execution of transaction VL01/VL02/VL32N”? CVEKP table is always empty.
      A: The variable is (SAPLV51G)IVEKP[]

    Error SSFCOMPOSER 152 solution

    Last week we have found an error in our Z-Smartform, which says nothing except “SSFCOMPOSER 152: Events are already defined.”
    It didn’t say what data related to the error, or even which part of the smartform acted wrong.

    After a bit debugging we’ve found the module with the proper position for a breakpoint:

    1. Open SE80 and “Function groups” inside it.
    2. Functional group STXBC.
    3. Open the subroutines folder.
    4. Set a breakpoint in ERR_WRITE routine.

    Now, carry out the smartform and we will get all the data related to the error with all the parameters.

    © Programador Sergio Paton

    Набор полезных программ

    Получить внешние вызовы ФМ, транзакций и многого другого внутри программы можно с помощью программы — RSINCL00.

    Транзакция ABAPDOCU — ABAP документация и примеры.

    Транзакция BIBS — примеры пользовательского интерфейса для ABAP программ.

    Транзакция DWDM — демо примеры с использованием Enjoy контролов.

    Программа ADBC_DEMO — демо программа ADBC API (для подключения к внешним базам данных).

    Транзакция SE83 — библиотека примеров с ALV и прочими контролами.

    Программа BALVBT01 — демонстрация множественного использования ALV.

    Программа SHOWICON — список всех иконок.

    Программа SHOWCOLO — все цвета используемые во WRITE или ALV.

    Программа SHOWLINE — всевозможные линии во write отчётах.

    Программа SHOWSYMB — символы.

    Программа AFX_CODE_SCANNER (или RPR_ABAP_SOURCE_SCAN) — поиск в исходных кодах.

    Программа RSBDCOS0 — выполнение системных команд на сервере.

    Программа REPTRAN — массовая выгрузка исходников.

    © abap-blog.ru

    Access a transaction without authorization (skip check)

    All the problem related to running a SAP transaction can now be resolved with the help of execution of a debugger.
    One of the major advantage of using the debugger is that while any changes are being made all those can be recorded in a log.
    Various ways to skip the authorization check:

    1. Within Function module ‘SMTR_KERNEL_CHECK_AUTHORITY’ insert a break-point. Press F7, clear the variable P_CANCEL_FLAG.
    2. Within Function module ‘RS_TRANSACTION_TEST’ insert a break-point on the ABAP code line ‘if sy-subrc = 0.’, straight after the call ‘AUTH_CHECK_TCODE’ id ‘TCODE’ field objectname. And change sy-subrc to 0.
    3. Just run any transaction using functional module SMTR_KERNEL_CHECK_AUTHORITY (still works if correcting Note was not implemented).

    P.S. Can’t run FM’s but can run programs? Just run the RSFUNCTIONBUILDER program.