ABAP
On distribution – is delivery packed?
Ruslan ABAP ABAP, Enhancement 0
FM WS_LM_CHANGE_DLV_DISTRIB_STATE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
ENHANCEMENT 1 YDISTRIBUTE. if ( sy-tcode eq 'VL06I' or sy-tcode eq 'VL06ID' ) and ( if_d_proctype eq proctype_inbdist ). "VL06I - do not process the enhancement if it distributes via other ways" "proctype_inbdist - checking only inbound deliveries" types: begin of t_params, paramval like yparamconst-paramval, end of t_params. data: lt_params type standard table of t_params, wa_params like line of lt_params, "work area (header line)" is_zles type boolean. "default abap_false." "which delivery types for checking/processing are defined in our Z-table?" select paramval from yparamconst into corresponding fields of table lt_params where paramid = 'LIEFERUNGSNUMMER'. if sy-subrc eq 0. field-symbols: <ls_lfart> type lipov. loop at ct_worktab assigning <ls_lfart>. read table lt_params with key paramval = <ls_lfart>-lfart transporting no fields. if sy-subrc eq 0. is_zles = abap_true. "all the selected delivery [types] are in yparamconst" endif. endloop. if is_zles eq abap_true. data: lt_wahl like gs_select occurs 0 with header line, begin of lt_wahl2 occurs 0, vbeln like likp-vbeln, verur like likp-verur, end of lt_wahl2, l_msg type c length 50, ans type char1. field-symbols: <ls_arbeit> type lipov, <ls_wahl2> like line of lt_wahl2. loop at ct_worktab assigning <ls_arbeit>. lt_wahl-vbeln = <ls_arbeit>-vbeln. collect lt_wahl. endloop. check not lt_wahl[] is initial. select vbeln verur from likp into table lt_wahl2 for all entries in lt_wahl where vbeln eq lt_wahl-vbeln. "in addition we checking if the field External ID isn't empty" loop at lt_wahl2 transporting no fields where verur eq space. endloop. if sy-subrc eq 0. message s000(Y_YSD) into l_msg. call function 'POPUP_TO_CONFIRM' exporting titlebar = 'Confirm' text_question = l_msg text_button_1 = 'Yes' text_button_2 = 'No' display_cancel_button = '' default_button = '2' importing answer = ans. if ans eq 2. return. endif. endif. clear l_msg. field-symbols: <ls_vepo> type lipov. data lt_vepo like VEPO occurs 0. loop at ct_worktab assigning <ls_vepo>. select vbeln from vepo into corresponding fields of table lt_vepo where vbeln eq <ls_vepo>-vbeln. if sy-subrc ne 0. message s001(Y_YSD) into l_msg. call function 'POPUP_TO_CONFIRM' exporting titlebar = 'Confirm' text_question = l_msg text_button_1 = 'Yes' text_button_2 = 'No' display_cancel_button = '' default_button = '2' importing answer = ans. if ans eq 2. return. endif. endif. endloop. endif. "is_zles" endif. endif. ENDENHANCEMENT. |
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
1 |
class zsaplink DEFINITION load. " Convenience for older SAP-Releases |
after the string
1 |
REPORT zsaplink. |
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
Ruslan ABAP, Allgemein PDF, smartforms 1
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\
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
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)
Ruslan ABAP, BC, nützlich authorization, trick 1
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:
- Within Function module ‚SMTR_KERNEL_CHECK_AUTHORITY‘ insert a break-point. Press F7, clear the variable P_CANCEL_FLAG.
- 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.
- 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.
ALV & Internal table
INCLUDE ZDATAI_TOP:
1 2 3 4 5 6 7 8 9 10 11 12 |
TABLES: vbap, marc, sscrfields. DATA: BEGIN OF sd_main OCCURS 0. data matnr like marc-matnr. data vbeln like vbap-vbeln. data arktx like vbap-arktx. data kdmat like vbap-kdmat. data stdpd like marc-stdpd. DATA: END OF sd_main. |
INCLUDE ZSD_SEL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
SELECTION-SCREEN SKIP. SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-001. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (32) text-a11 FOR FIELD p_datef. PARAMETERS : p_datef LIKE sy-datum DEFAULT space. "OBLIGATORY. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (32) text-a12 FOR FIELD p_datet. PARAMETERS : p_datet LIKE sy-datum DEFAULT sy-datum OBLIGATORY. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN SKIP. SELECTION-SCREEN BEGIN OF BLOCK dest WITH FRAME TITLE text-e10. PARAMETERS : dest LIKE rfcdisplay-rfcdest DEFAULT 'NONE'. SELECTION-SCREEN END OF BLOCK dest. SELECTION-SCREEN BEGIN OF BLOCK optional WITH FRAME TITLE d10. SELECT-OPTIONS : s_matnr FOR vbap-matnr. SELECT-OPTIONS : s_vbeln FOR vbap-vbeln. "Transaction Code SELECTION-SCREEN END OF BLOCK optional. SELECTION-SCREEN END OF BLOCK selection. SELECTION-SCREEN SKIP. SELECTION-SCREEN PUSHBUTTON 1(10) bt1 USER-COMMAND uc2. AT SELECTION-SCREEN. CASE sscrfields-ucomm. WHEN 'UC2'. CLEAR: s_matnr, s_vbeln, p_datef, p_datet. ENDCASE. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
REPORT Z_ITJX INCLUDE zdatai_top. INCLUDE zsd_sel. TYPE-POOLS: slis. " SLIS contains all the ALV data types DATA: it_fieldcat TYPE slis_t_fieldcat_alv, wa_fieldcat TYPE slis_fieldcat_alv. DATA: it_vbak LIKE sd_main OCCURS 0. SELECT * FROM vbap "UP TO 500 ROWS INNER JOIN marc ON vbap~matnr EQ marc~matnr " AND vbak~vbeln EQ vbap~vbeln INTO CORRESPONDING FIELDS OF TABLE sd_main WHERE vbap~matnr IN s_matnr. wa_fieldcat-fieldname = 'VBELN'. " Fieldname in the data table (sd_main) wa_fieldcat-seltext_m = 'Sales document'. " Column description in the output APPEND wa_fieldcat TO it_fieldcat. wa_fieldcat-fieldname = 'KDMAT'. wa_fieldcat-seltext_m = 'Client material'. APPEND wa_fieldcat TO it_fieldcat. wa_fieldcat-fieldname = 'MATNR'. wa_fieldcat-seltext_m = 'Material number'. APPEND wa_fieldcat TO it_fieldcat. wa_fieldcat-fieldname = 'ARKTX'. wa_fieldcat-seltext_m = 'Description'. APPEND wa_fieldcat TO it_fieldcat. wa_fieldcat-fieldname = 'STDPD'. wa_fieldcat-seltext_m = 'KMAT'. APPEND wa_fieldcat TO it_fieldcat. *Pass data and field catalog to ALV function module to display ALV list CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = it_fieldcat TABLES t_outtab = sd_main EXCEPTIONS program_error = 1 OTHERS = 2. |
ABAP: rename file on Application server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
form datei_umbenennen using lv_altpfad lv_neupfad type string. data: lv_eof_reached type c, lv_buffer(20480), lv_buflen type i. open dataset lv_altpfad for input in binary mode. if sy-subrc ne 0. raise open_input_file_failed. endif. open dataset lv_neupfad for output in binary mode. if sy-subrc ne 0. raise open_output_file_failed. endif. clear lv_eof_reached. do. clear lv_buffer. read dataset lv_altpfad into lv_buffer length lv_buflen. if sy-subrc = 4. lv_eof_reached = 'X'. elseif sy-subrc > 4. raise read_block_failed. endif. transfer lv_buffer to lv_neupfad length lv_buflen. if sy-subrc ne 0. raise write_block_failed. endif. if lv_eof_reached eq 'X'. exit. endif. enddo. close dataset lv_altpfad. close dataset lv_neupfad. if sy-subrc <> 0. raise close_output_file_failed. endif. delete dataset lv_altpfad. endform. |