31 Ağustos 2008 Pazar
Info structure & evaluation structure
mcs7 -- mcs8 -- mcs9
Info Structure
Standard number range of SAP is upto 499 and we can create customized Info Structures from 501 to 999.
mc21 -- mc22 -- mc23
The information structures are files of special statistics data that constitute an important element of the information systems. They form data basis for the standard analyses. Even planning is based on the information structures.
Standard Information Structures
Self-Defined Information Structures
Self-defined information structures enable you to add your own enhancements to the information systems. You can combine information structures to suit your own needs as well as define your own rules for updating. You can make use of the entire functional range in LIS to create your own information structures. You can use the standard analyses and the flexible analyses to evaluate the user-defined information structures and you can also create planning data for them.
The functions for the user-defined information structures are found in Customizing under the Logistics Information System. The complete functionality can be found under the menu option Data Basis.
You can find further information in the Implementation Guide.
To call up the Implementation Guide, proceed as follows:
From the R/3 system menu, select Tools ® Hypertext ® Structure ® IMG
A complete list of all of the available Implementation Guides will appear.
Place the cursor on Logistics General and select Edit ® Explode/hide.
A list of all of the documents that are assigned to Logistics General will appear.
Place the cursor on Logistics Information System and select Edit ® Explode/hide.
A list of all of the documents that are assigned to the Logistics Information System will appear.
You will find the Implementation Guide you require under Logistics Data Warehouse ® Data Basis.
Updating Statistical Data
The updating of statistical data can take place as an U1-update (update with delayed start) or a U2 update (statistical update).
With Release 4.6C you can also use V3 updating (user-defined period of time).
For every standard information structure, you can define the type of updating and the frequency with which the statistical data should be cumulated (on a daily, weekly, or monthly basis, or at posting period intervals). You do this using the Logistics Information System Configuration menu (see also Updating ).
You can improve the monitoring of the update process with the help of a user-specific list known as the update log. This shows details of the last event to be affected by statistics updating (see also Update Control ).
Reporting Tools in SAP
InfoSet Query (Ad Hoc Query)
QuickViewer
You can create InfoSets from various data sources , including logical databases, tables, table joins, and so on. The best business practice is to use the SAP delivered logical databases as your data source, because they were created for this purpose and there is at least one logical database delivered with your system for each module within SAP, including Accounting, Personnel Management, and so on. The F1S database used in this example is the training database that SAP uses in its training classes based on a fictional airline scheduling system. It is best to use this database for your test cases.
In contrast to using SAP Query and InfoSet (Ad Hoc) Query, you do not need to configure User Groups and InfoSets to use QuickViewer. However, if they have already created, you can use them. Users simply select a data source (table, database view, table join, logical database, or InfoSet) when building their QuickView.
Both Report Painter and Report Writer can be used to report on the following tables and tables types:
-- Evaluation structures set up in the Logistics Information System (LIS). These structures normally begin with an "S" or "ZF." Several different tables and views within the R/3 System can be added as evaluation structures.
Note: You cannot add cluster tables, such as BSEG.
--CCSS is used for Cost Center Accounting (CO-CCA), Internal Orders (CO-OPA), Activity Based Costing (CO-ABC) and for cost element reports in Project Systems (PS).
--GLFUNCT is used for functional area reporting in cost-of-sales accounting.
--GLPCT and GLPCOP are used for Profit Center Accounting (CO-PCA/EC-PCA).
--FILC is used for Legal Consolidations (FI-LC).
--COFIT is used for the Controlling Reconciliation Ledger (CO-CEL).
--ZZ tables are created for the Special Purpose Ledger (FI-SL).
--FIMC is used for consolidations in the Enterprise Controlling module (EC-LC).
--GLT0 is used for Financial Accounting (General Ledger) reports by account, company, and business area (FI-GL).
--KKBC, KKBE, and KKBU are used for the Controlling Product Costing module (CO-Costing).
Report Writer
Set types:
Basic sets , Single Dimension sets,Predefined column , Multi-dimensional sets
Mali İşler-->Maliyet muhasebesi veKontrol -->MasrafYeriMuhasebesi--> BilgiSistemi --> Araçlar --> Report Painter
Report Painter
Library
Library determines the following in report painter report:
Table that can be used in the report
Charaterstics that can be used in the report
Key Figures that can be used in the report
Basic Key Figures that can be used in the report
In order that the Report Writer can report on a specific database table, it must be entered in the control table T804A. The database table must not exist as a physical table, but can also be defined as a logical table in the Report Writer (table T804E), and contain several physical tables.
Peki library için tablo nereden yaratcaz??
The Table is the standard structure based on which you will be creating your Library and report.
The Report Writer can only report on tables if the attributes of these tables that are relevant for reporting are defined in control tables.
You should be able to make a Data Dictionary table available to Report Painter / Writer if you can create an Evaluation structure for the table .
To create an Eval structure In Logistics :
Tcode MCS7 - Create evaluation Structure.
(Path: Logistics >Sales & Distribution >Sales Info System >Flexible Analysis >Evaluation
Structure >Create)
You could name the Eval Structure "ZF*****", (must begin with "ZF").
Then click
Enter the DD table "******". And click the check mark.
Then click
you right click
you can select), then
Do the same for
Then generate the Eval structure
After you created the Eval structure, you can create a library with this Eval structure (table) in it.
http://www.sapdb.info/wp-content/uploads/2008/08/report_painter.pdf
30 Ağustos 2008 Cumartesi
Select-Options Gizleme islemi
**************************************************
select-options: SO_BELNR for bkpf-belnr modif id g1.......
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'G1'.
screen-active = '0'.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
**************************************************
İkinci yol ise, No-Display kullanmaktır.
SO_BELNR for bkpf-belnr no-display.
Secim Ekraninda DropDownList kullanimi
TYPE-POOLS: vrm.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
name = 'PS_PARM'.
value-key = '1'.
value-text = 'Line 1'.
APPEND value TO list.
value-key = '2'.
value-text = 'Line 2'.
APPEND value TO list.
*Key: Seçildikten sonra yakalayacağımız anahtar alan.
*Text: Seçim ekranında listbox içinde ki text değer.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
Start-Of-Selection.
...
...
End-Of-Selection.
String islemleri
DATA TEXT(100) VALUE 'Texas California New Mexico Louisiana Oregon'.
SEARCH TEXT FOR 'California'.
IF SY-SUBRC NE 0.
WRITE 'Not found'.
ENDIF.
SEARCH TEXT FOR 'cAliforniA'.
IF SY-SUBRC NE 0.
WRITE 'Not found'.
ENDIF.
SEARCH TEXT FOR 'New M'.
IF SY-SUBRC NE 0.
WRITE 'Not found'.
ENDIF.
* Replacing & translating .
DATA: STRING(80),EXPRESSION(30).
STRING = 'Variable: &. The variable & is substituted later.'.
REPLACE '&' WITH 'X' INTO STRING.
WRITE / STRING.
TRANSLATE STRING USING '&X'.
WRITE / STRING.EXPRESSION = 'a ** 2 + b ** 2 = c ** 2'.
TRANSLATE EXPRESSION USING 'axbycz'.
WRITE / EXPRESSION.
REPLACE ',' WITH '' INTO lv_degisken.
REPLACE ALL OCCURRENCES OF ',' IN lv_degisken WITH ''.
*Boşlukları silerek shift işlemi
NAMES = 'Joanne___'.
SHIFT NAMES RIGHT DELETING TRAILING SPACE.
WRITE / NAMES.
Progress Bar yapimi
REPORT Z_Progress.
TYPES: BEGIN OF t_mara,
matnr LIKE mara-matnr,
END OF t_mara.
DATA: it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0,
wa_mara TYPE t_mara.
DATA: mara_lines TYPE i,
gd_percent TYPE i.
START-OF-SELECTION.
SELECT matnr INTO TABLE it_mara FROM mara.
CHECK sy-subrc EQ 0.
mara_lines = sy-dbcnt.
clear: gd_percent.
LOOP AT it_mara INTO wa_mara.
PERFORM progress_bar USING 'Veriler alınıyor...'(001)
sy-tabix mara_lines.
ENDLOOP.
FORM progress_bar USING p_value p_tabix p_nlines.
DATA: w_text(40),
w_percentage TYPE p,
w_percent_char(3).
w_percentage = ( p_tabix / p_nlines ) * 100.
w_percent_char = w_percentage.
SHIFT w_percent_char LEFT DELETING LEADING ' '.
CONCATENATE p_value w_percent_char '% Tamamlandı'(002) INTO w_text.
*bu kontrolü büyük verilerde loop yaptığımızda tekrar
*tekrar görünmesini engellemek için yapıyoruz
if w_percentage gt gd_percent or p_tabix eq 1.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING percentage = w_percentage
text = w_text.
gd_percent = w_percentage.
endif.
endform.
" PROGRESS_BAR
WRITE: /20 'Bitti" OK'.
Dialog Ekranini Popup Olarak Cagirma
çağırdığımız ekran tüm ekranı kapladığı için, zaman zaman bunun olmasını istemeyiz.
İstediğimiz boyutlarda popup ekranı gibi çağırmak için sonuna starting at komutunu ekleriz. Daha sonra vereceğimiz kordinatlara göre ekran gelecektir.
call screen '0300' starting at 20 11 ending at 70 24.
Malzeme Olcu Donusumu
Örneğin 1 KG kaç M2 ya da5 Koli kaç Adet yapar gibi.
Bu çevirimleri yapmak için, MARC tablosuna gidip
dönüşümlerle uğraşmak yerine;
MD_CONVERT_MATERIAL_UNIT
Fonksiyonunu kullanabiliriz.
Örnek;
DATA:pmatnr LIKE mara-matnr,
pmein1 LIKE mara-meins,
pmein2 LIKE mara-meins,
pmeng1 LIKE ekpo-menge,
pmeng2 LIKE ekpo-menge.
CLEAR : pmatnr, pmein1,
pmein2, pmeng1, pmeng2.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = pmatnr "malzeme numaramız
i_in_me = pmein1 "dönüşecek ölçü birimi
i_out_me = pmein2 "hangi ölçüye dönüşecek ?
i_menge = pmeng1 "miktar
IMPORTING
e_menge = pmeng2 "dönen miktar
EXCEPTION
Serror_in_application = 1
error = 2
OTHERS = 3.
REUSE_ALV_FIELDCATALOG_MERGE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'ZPYP_STOK_GENEL'
i_internal_tabname = 'PYP_ITAB'
i_inclname = 'ZPYP_STOK_GENEL'
CHANGING
ct_fieldcat = gt_fieldcat[].
ABAP'ta Sayıyı Yazıya Çevirmek
SD Tablo Takibi
Fatura 90002935, kalem 101 ise;
VBFA: VBELN = 90002935, POSNN = 101, VBTYP_N = M, VBTYP_V = J diye gidiyorum. VBELV = 80008713, POSNV = 10 geliyor. Bu, teslimattır.
VBFA: VBELN = 80008713, POSNN = 10, VBTYP_N = J, VBTYP_V = C diye gidiyorum. VBELV = 2344, POSNV = 101 geliyor. Bu, sipariştir.
VBFA: VBELN = 2344, POSNN = 101, VBTYP_N = C, VBTYP_V = G diye gidiyorum. VBELV = 8980000006, POSNV = 101 geliyor. Bu, sözleşmedir.
Bu yöntem, geçiş çapta veri çekmek söz konusu olduğunda performans açısından çok iyi sonuç vermeyebilir.
ABAP'ta Mesajı Metne Çevirmek
SmartForm Sistem Parametreleri
Reading Table Fields In ABAP
How To Obtain Material Price in ABAP
*&---------------------------------------------------------------------*
*& Form read_function_prices
*&---------------------------------------------------------------------*
FORM read_function_prices.
DATA:
BEGIN OF lt_kalnr OCCURS 0,
werks LIKE mbew-werks,
matnr LIKE mbew-matnr,
kalnr LIKE mbew-kaln1,
END OF lt_kalnr,
lt_ckmlpp TYPE ckmlpp OCCURS 0 WITH HEADER LINE,
lt_ckmlcr TYPE ckmlcr OCCURS 0 WITH HEADER LINE,
lt_ckmlhd TYPE ckmlhd OCCURS 0 WITH HEADER LINE,
lv_bdatj TYPE ckmlpp-bdatj,
lv_poper TYPE ckmlpp-poper.
* Başlık tablosuna malzemelerimizi dolduralım
LOOP AT gt_alvitem.
CLEAR lt_ckmlhd.
lt_ckmlhd-kalnr = gt_alvitem-kaln1.
APPEND lt_ckmlhd.
ENDLOOP.
* Dönemler
lv_poper = p_poper.
lv_bdatj = p_gjahr.
* Fonksiyonu çağıralım
CALL FUNCTION 'CKMS_PERIOD_READ_ONLY'
EXPORTING
i_period_from = lv_poper
i_year_from = lv_bdatj
i_period_to = lv_poper
i_year_to = lv_bdatj
TABLES
et_ckmlpp = lt_ckmlpp[]
et_ckmlcr = lt_ckmlcr[]
it_ckmlhd = lt_ckmlhd[].
* Okuduğumuz fiyatları geri döndürelim
LOOP AT lt_ckmlcr WHERE curtp EQ gc_curtp.
READ TABLE lt_ckmlpp WITH KEY kalnr = lt_ckmlcr-kalnr
bdatj = lt_ckmlcr-bdatj
poper = lt_ckmlcr-poper
untper = lt_ckmlcr-untper.
CHECK sy-subrc EQ 0.
READ TABLE gt_alvitem WITH KEY kaln1 = lt_ckmlcr-kalnr.
CHECK sy-subrc EQ 0.
gt_alvitem-salk3 = lt_ckmlcr-salk3.
gt_alvitem-lbkum = lt_ckmlpp-lbkum.
MODIFY gt_alvitem INDEX sy-tabix.
ENDLOOP.
ENDFORM. " read_function_prices
Tips & Tricks #1
Selection screen de mara tablosunda olmayan bir urunun girilmesi durumunda programi bastan calismasini engellemek icin "value check" kullanilir.
2)Abap kodlarininda arama yapmak için ;
Sistemdeki ABAP programlarının kodları içerisinde arama yapmak için, RSRSCAN1 veya RPR_ABAP_SOURCE_SCAN programını kullanabilirsiniz.
29 Ağustos 2008 Cuma
Forming fieldcat from begin of structure ZFB03
*& Report ZFI_DOCLIST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
"INCLUDE ZFIDOCLISTTOP . " global Data
REPORT ZFI_DOCLIST.
* INCLUDE ZFIDOCLISTO01 . " PBO-Modules
* INCLUDE ZFIDOCLISTI01 . " PAI-Modules
* INCLUDE ZFIDOCLISTF01 . " FORM-Routines
TABLES: BKPF , BSEG .
DATA: BEGIN OF gen_struct,
BUKRS LIKE BKPF-BUKRS,
GSBER LIKE BSEG-GSBER,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLART LIKE BKPF-BLART,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
XBLNR LIKE BKPF-XBLNR,
CPUDT LIKE BKPF-CPUDT,
USNAM LIKE BKPF-USNAM,
END OF gen_struct.
DATA: BEGIN OF doc_struct,
BUKRS LIKE BKPF-BUKRS,
GSBER LIKE BSEG-GSBER,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLART LIKE BKPF-BLART,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
XBLNR LIKE BKPF-XBLNR,
CPUDT LIKE BKPF-CPUDT,
USNAM LIKE BKPF-USNAM,
END OF doc_struct.
DATA: GEN_TABLE like TABLE OF gen_struct WITH HEADER LINE.
DATA: DOC_TABLE like TABLE OF doc_struct WITH HEADER LINE.
DATA: OK_CODE LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV_GRID_0100_CONT1',
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GT_FIELDCAT TYPE lvc_t_fcat.
DATA: KT_FIELDCAT TYPE KKBLO_T_FIELDCAT.
DATA: WA_KT_FIELDCAT type line of KKBLO_T_FIELDCAT.
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*hotspot click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION .
*Handle Hotspot Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING
e_row_id e_column_id es_row_no.
ENDMETHOD . "handle_hotspot_click
ENDCLASS .
DATA: gr_event_handler TYPE REF TO lcl_event_handler.
SELECTION-SCREEN BEGIN OF block ksa.
SELECT-OPTIONS: s_bukrs FOR bkpf-bukrs OBLIGATORY ,
s_belnr FOR bkpf-belnr ,
s_gsber FOR bseg-gsber ,
s_gjahr FOR bkpf-gjahr default sy-datum+0(4)
OBLIGATORY ,
s_blart FOR bkpf-blart ,
s_bldat FOR bkpf-bldat ,
s_cpudt FOR bkpf-cpudt ,
s_usnam FOR bkpf-usnam
default sy-uname,
s_budat FOR bkpf-budat ,
s_xblnr FOR bkpf-xblnr .
SELECTION-SCREEN END OF block ksa.
INITIALIZATION.
DATA new_date LIKE sy-datum.
CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'
EXPORTING
months = '-1'
olddate = sy-datum
IMPORTING
newdate = new_date.
s_bldat-sign = 'I'.
s_bldat-option = 'BT'.
s_bldat-low = new_date.
s_bldat-high = sy-datum.
append s_bldat.
start-of-selection.
SELECT * INTO CORRESPONDING FIELDS OF TABLE doc_Table
FROM BKPF
WHERE bukrs in s_bukrs AND
belnr in s_belnr AND
gjahr in s_gjahr AND
blart in s_blart AND
bldat in s_bldat AND
budat in s_budat AND
xblnr in s_xblnr AND
cpudt in s_cpudt AND
usnam in s_usnam .
LOOP AT doc_Table.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF gen_Table from BSEG
where bukrs = doc_Table-bukrs and
belnr = doc_Table-belnr and
gjahr = doc_Table-gjahr and
gsber in s_gsber .
if sy-subrc = 0.
gen_Table-blart = doc_Table-blart.
gen_Table-bldat = doc_Table-bldat.
gen_Table-budat = doc_Table-budat.
gen_Table-xblnr = doc_Table-xblnr.
gen_Table-CPUDT = doc_Table-CPUDT.
gen_Table-USNAM = doc_Table-USNAM.
APPEND gen_Table.
endif.
ENDLOOP.
CALL SCREEN 100.
PERFORM READ_DATA.
FORM READ_DATA.
ENDFORM.
FORM INIT_FIELDCAT .
call function 'K_KKB_FIELDCAT_MERGE'
exporting
i_callback_program = sy-repid
i_tabname = 'GEN_STRUCT'
i_inclname = sy-repid
I_BYPASSING_BUFFER = 'X'
changing
ct_fieldcat = kt_fieldcat[]
exceptions
inconsistent_interface = 1
others = 2.
loop at kt_fieldcat into wa_kt_fieldcat.
IF WA_KT_FIELDCAT-FIELDNAME = 'BELNR'.
wa_kt_fieldcat-hotspot = 'X'.
modify kt_fieldcat from wa_kt_fieldcat.
ENDIF.
endloop.
call function 'LVC_TRANSFER_FROM_KKBLO'
exporting
it_fieldcat_kkblo = Kt_fieldcat[]
importing
et_fieldcat_lvc = gt_fieldcat[].
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_INTERNAL_TABNAME = 'GEN_TABLE'
CHANGING
ct_fieldcat = gt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM.
FORM DISPLAY_ALV.
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
CREATE OBJECT gr_event_handler .
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
"EXPORTING
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = gen_table[].
SET HANDLER gr_event_handler->handle_hotspot_click FOR grid1.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS_100'.
"SET TITLEBAR 'Belge Listesi'.
PERFORM INIT_FIELDCAT.
PERFORM DISPLAY_ALV.
ENDMODULE. " STATUS_0100 OUTPUT
"INCLUDE ZFI_DOCLIST_STATUS_0100O01.
INCLUDE ZFI_DOCLIST_USER_COMMAND_01I01.
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE gen_table INDEX is_row_no-row_id .
SET PARAMETER ID 'BUK' FIELD gen_table-bukrs.
SET PARAMETER ID 'BLN' FIELD gen_table-belnr.
SET PARAMETER ID 'GJR' FIELD gen_table-gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN .
ENDFORM.
Storing document in SAP (GET)...Business Document Navigator
Get document / file stored in SAP Business Document.
REPORT ZAALTES1 line-size 300.
INCLUDE officeintegrationinclude. " used by DOI
* Get descr_list
TYPES: BEGIN OF SOI_DOCUMENT_TYPE_DESCR,
DOCUMENT_TYPE TYPE SOI_DOCUMENT_TYPE, " prog id
TYPE_FULL_NAME(70) TYPE C, " full name
TYPE_SHORT_NAME(20) TYPE C, " short name
APPLICATION_NAME(50) TYPE C, " application name
SUPPORTED_INTERFACES(256) TYPE C, " supported SAP interfaces
AVAILABLE(1) TYPE C, " X on return when available
END OF SOI_DOCUMENT_TYPE_DESCR.
DATA:
descr_list TYPE soi_document_type_descr_list,
wa_descr_list TYPE SOI_DOCUMENT_TYPE_DESCR,
retcode TYPE t_oi_ret_string.
DATA: application_cntl TYPE REF TO i_oi_ole_container_control.
* ----------
* -- connection table and the internal structure of the ITAB
DATA: BEGIN OF i_bds_conn OCCURS 10. " ITAB for the actual
INCLUDE STRUCTURE bdn_con. " document
DATA: objecttext LIKE toasp-objecttext,
objecttext2 LIKE toasd-objecttext,
objecttext3 LIKE toasr-objecttext,
ntext LIKE tojtt-ntext,
END OF i_bds_conn.
DATA: BEGIN OF bds_doctype_list OCCURS 10,
mandt TYPE mandt,
classname LIKE bapibds01-classname,
contrep LIKE i_bds_conn-contrep,
docuclass LIKE i_bds_conn-docuclass,
docuclass_text LIKE toasd-objecttext,
doc_type LIKE i_bds_conn-doc_type,
doc_type_text LIKE toasp-objecttext,
appl_type LIKE toadd-appl_type,
appl_type_text(50) TYPE c,
standard LIKE toadv-standard,
check_box LIKE toadv-standard,
END OF bds_doctype_list.
TYPES: ole2_application(70) TYPE c.
DATA:
logical_system LIKE bds_conn00-log_system,
display_struc LIKE i_bds_conn OCCURS 2 WITH HEADER LINE,
classname_select LIKE bdn_con-classname,
classtype_select LIKE bdn_con-classtype,
objkey_select LIKE bdn_con-objkey,
mask(20) TYPE c,
signature LIKE bapisignat OCCURS 1 WITH HEADER LINE,
build_all(1) TYPE c, " get all OLE apps
ole2_app TYPE ole2_application,
i_ole2_app_text LIKE bds_doctype_list-appl_type_text,
d_tabix LIKE sy-tabix,
vartemp
.
TYPES: BEGIN OF ole_apps_struc,
appl_type LIKE toadd-appl_type,
appl_type_text LIKE bds_doctype_list-appl_type_text,
mimetype LIKE bdn_con-mimetype,
docuclass LIKE bdn_con-docuclass,
END OF ole_apps_struc.
DATA: ole_apps TYPE ole_apps_struc OCCURS 5.
PARAMETERS: p_class LIKE bdn_con-classname OBLIGATORY,
p_objct LIKE bdn_con-objkey OBLIGATORY.
start-of-selection.
classname_select = p_class.
classtype_select = 'OT'.
objkey_select = p_objct.
PERFORM f_bds_call_navigator.
at line-selection.
PERFORM f_line_selection.
FORM f_bds_call_navigator.
* Function : BDS_CALL_NAVIGATOR
* -- data declaration -- *
DATA: i_connections LIKE bdn_con OCCURS 0 WITH HEADER LINE,
calling_signa LIKE bapisignat OCCURS 0 WITH HEADER LINE,
i_count LIKE sy-index,
i_gui_type LIKE bapibds01-type,
web_excluding LIKE bdn_fkt OCCURS 1 WITH HEADER LINE.
* -- get all connections for the objtype/objkey -- *
CALL FUNCTION 'BDS_ALL_CONNECTIONS_GET'
EXPORTING
logical_system = logical_system
classname = classname_select
classtype = classtype_select
objkey = objkey_select
client = sy-mandt
all = ' ' " <- get the newest version
IMPORTING
count = i_count
TABLES
signature = signature
all_connections = i_connections
* framework = framework
* -- Begin correction 388230 ------------------------------ *
* EXCEPTIONS
* no_objects_found = 1
* error_kpro = 2
* internal_error = 3
* OTHERS = 4.
* IF sy-subrc > 1.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
* RAISING internal_error.
* ENDIF.
EXCEPTIONS
no_objects_found = 1
error_kpro = 2
internal_error = 3
not_authorized = 4
OTHERS = 5.
*End Function : BDS_CALL_NAVIGATOR
*Function : BDS_DISPLAY_LIST_VIA_TREE
* -- get some text fields -- *
DATA:
i_toasp LIKE toasp OCCURS 1 WITH HEADER LINE,
i_toasd LIKE toasd OCCURS 1 WITH HEADER LINE,
i_toasr LIKE toasr OCCURS 1 WITH HEADER LINE,
class_text like tojtt-ntext
.
SELECT * FROM toasp INTO TABLE i_toasp WHERE language = sy-langu.
SELECT * FROM toasd INTO TABLE i_toasd WHERE language = sy-langu.
SELECT * FROM toasr INTO TABLE i_toasr WHERE language = sy-langu.
APPEND LINES OF i_connections TO i_bds_conn.
LOOP AT i_bds_conn.
IF i_bds_conn-doc_type <> space. " -> Corr. (402788) A.M.
READ TABLE i_toasp WITH KEY ar_object = i_bds_conn-doc_type.
IF sy-subrc = 0.
i_bds_conn-objecttext = i_toasp-objecttext.
ENDIF.
ENDIF. " -> Corr. (402788) A.M.
READ TABLE i_toasr WITH KEY archiv_id = i_bds_conn-contrep.
IF sy-subrc = 0.
i_bds_conn-objecttext3 = i_toasr-objecttext.
ENDIF.
IF i_bds_conn-docuclass <> space.
READ TABLE i_toasd WITH KEY doc_type = i_bds_conn-docuclass.
IF sy-subrc = 0.
i_bds_conn-objecttext2 = i_toasd-objecttext.
ENDIF.
ENDIF.
i_bds_conn-ntext = class_text.
MODIFY i_bds_conn.
ENDLOOP.
*End Function : BDS_DISPLAY_LIST_VIA_TREE
skip.
LOOP AT i_bds_conn.
d_tabix = sy-tabix.
HIDE d_tabix.
WRITE : / i_bds_conn-BDN_TAB_I,
i_bds_conn-descript,
(50) i_bds_conn-comp_id,
i_bds_conn-objecttext,
i_bds_conn-objecttext2,
i_bds_conn-objecttext3,
i_bds_conn-ntext.
ENDLOOP.
CLEAR d_tabix.
EXIT.
PERFORM f_get_registered_doc_types.
*Program: LBDS_TOOLSF01, Form: display_selected_document
MOVE-CORRESPONDING i_bds_conn TO display_struc.
* -- find ole2_app -- *
build_all = ' '.
PERFORM get_ole2_app2 TABLES descr_list
USING display_struc-docuclass
display_struc-mimetype
ole2_app i_ole2_app_text
build_all.
ENDFORM. "f_bds_call_navigator
*&---------------------------------------------------------------------*
*& Form display_selected_document_out
*&---------------------------------------------------------------------*
* display selected document NOT in-place.
*----------------------------------------------------------------------*
FORM display_selected_document_out
TABLES display_struc STRUCTURE i_bds_conn.
* -- data declaration -- *
DATA: display_signature LIKE bapisignat OCCURS 5 WITH HEADER LINE.
* -------------------------------------------------------------------- *
CLEAR: display_signature.
REFRESH: display_signature.
READ TABLE display_struc INDEX 1.
display_signature-doc_count = '1'.
display_signature-doc_id = display_struc-loio_id.
display_signature-doc_ver_no = display_struc-doc_ver_no.
display_signature-doc_var_id = display_struc-doc_var_id.
display_signature-doc_var_tg = display_struc-doc_var_tg.
APPEND display_signature.
CALL FUNCTION 'BDS_OBJECT_DISPLAY_INTERN'
EXPORTING
logical_system = display_struc-log_system
classname = display_struc-classname
classtype = display_struc-classtype
client = display_struc-client
object_key = display_struc-objkey
bds_docid = display_struc-bds_docid
bds_contrep = display_struc-contrep
bds_docuclass = display_struc-docuclass
TABLES
signature = display_signature
EXCEPTIONS
error_kpro = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " display_selected_document_out
*&---------------------------------------------------------------------*
*& Form GET_OLE2_APP2
*&---------------------------------------------------------------------*
* Get the correct OLE-App.
*----------------------------------------------------------------------*
FORM get_ole2_app2 TABLES descr_list
USING i_docuclass LIKE bdn_con-docuclass
i_mimetype LIKE bdn_con-mimetype
ole2_app LIKE toadd-appl_type
ole2_app_text LIKE bds_doctype_list-appl_type_text
build_all LIKE bdn_con-stor_tab.
* -- Data declaration ------------------------------------------------ *
TYPES: BEGIN OF document_type_descr,
document_type(70) TYPE c,
type_full_name(70) TYPE c,
type_short_name(20) TYPE c,
application_name(50) TYPE c,
supported_interfaces(256) TYPE c,
available(1) TYPE c,
END OF document_type_descr.
DATA: i_ole2_app TYPE toadd OCCURS 1 WITH HEADER LINE,
descr_list_struc TYPE document_type_descr,
local_langu LIKE sy-langu,
ole_apps_line TYPE ole_apps_struc,
temp_mimetype LIKE bdn_con-mimetype.
* -- Initilize Data -------------------------------------------------- *
local_langu = sy-langu.
* -------------------------------------------------------------------- *
IF build_all = ' '. " -> get a special ole_type
SET LOCALE LANGUAGE local_langu.
TRANSLATE i_mimetype TO LOWER CASE.
SET LOCALE LANGUAGE space.
IF i_docuclass <> space.
SELECT * INTO TABLE i_ole2_app FROM toadd
WHERE doc_type = i_docuclass.
temp_mimetype = i_mimetype.
i_mimetype = space.
ELSEIF i_mimetype <> space.
SELECT * INTO TABLE i_ole2_app FROM toadd
WHERE mimetype = i_mimetype.
i_docuclass = space.
temp_mimetype = i_mimetype.
ENDIF.
CLEAR i_ole2_app.
LOOP AT i_ole2_app.
IF i_ole2_app-appl_type <> space.
IF ( i_ole2_app-appl_type = 'EAIWEB.WEBVIEWER2D' OR
i_ole2_app-appl_type = 'EAIWEB.WEBVIEWER3D' OR
i_ole2_app-appl_type = 'SAPHTML' ).
ole2_app = i_ole2_app-appl_type.
i_mimetype = temp_mimetype.
EXIT.
ENDIF.
LOOP AT descr_list INTO descr_list_struc.
SET LOCALE LANGUAGE local_langu.
TRANSLATE descr_list_struc-document_type TO UPPER CASE.
SET LOCALE LANGUAGE space.
IF i_ole2_app-appl_type = descr_list_struc-document_type.
ole2_app = i_ole2_app-appl_type.
ole2_app_text = descr_list_struc-application_name.
i_docuclass = i_ole2_app-doc_type.
i_mimetype = i_ole2_app-mimetype.
EXIT.
ENDIF.
ENDLOOP.
ELSE.
ole2_app = space.
ole2_app_text = space.
i_mimetype = i_ole2_app-mimetype.
i_docuclass = i_ole2_app-doc_type.
EXIT.
ENDIF.
ENDLOOP.
ELSE. " -> get the complete list
CLEAR i_ole2_app.
SELECT * INTO TABLE i_ole2_app FROM toadd.
LOOP AT i_ole2_app.
IF ( i_ole2_app-appl_type <> space AND
i_ole2_app-appl_type <> 'ACROEXCH.DOCUMENT' ). "#EC NOTEXT
LOOP AT descr_list INTO descr_list_struc.
SET LOCALE LANGUAGE local_langu.
TRANSLATE descr_list_struc-document_type TO UPPER CASE.
SET LOCALE LANGUAGE space.
IF i_ole2_app-appl_type = descr_list_struc-document_type.
ole_apps_line-appl_type = i_ole2_app-appl_type.
ole_apps_line-appl_type_text =
descr_list_struc-application_name.
ole_apps_line-docuclass = i_ole2_app-doc_type.
ole_apps_line-mimetype = i_ole2_app-mimetype.
APPEND ole_apps_line TO ole_apps.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
SORT ole_apps BY appl_type.
DELETE ADJACENT DUPLICATES FROM ole_apps COMPARING appl_type.
ENDIF.
ENDFORM. " GET_OLE2_APP2
*&---------------------------------------------------------------------*
*& Form f_get_registered_doc_types
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_registered_doc_types.
if application_cntl is initial.
* -- Create Container Control -- *
call method c_oi_ole_control_creator=>get_ole_container_control
importing
control = application_cntl
retcode = retcode.
if retcode <> c_oi_errors=>ret_ok.
call method c_oi_errors=>show_message
exporting
type = 'E'.
endif.
call method application_cntl->get_registered_doc_types
exporting
interface_type = ' '
importing
descr_list = descr_list
retcode = retcode.
if retcode <> c_oi_errors=>ret_ok.
call method c_oi_errors=>show_message
exporting
type = 'E'.
endif.
endif.
ENDFORM. " f_get_registered_doc_types
*&---------------------------------------------------------------------*
*& Form f_line_selection
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_line_selection.
READ TABLE i_bds_conn INDEX d_tabix.
CHECK sy-subrc = 0.
MOVE-CORRESPONDING i_bds_conn TO display_struc.
PERFORM display_selected_document_out TABLES display_struc.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2.
IF sy-subrc <> 0.
MESSAGE e324(sbds).
ELSE.
WRITE :/ 'success'.
ENDIF.
ENDFORM. " f_line_selection
Storing document in SAP (Upload)...Business Document Navigator
To go to the Business Document Navigator, choose Office -> Business Documents -> Documents -> Find (transaction code : OAOR).
In the upper part of the screen, the relevant documents, sorted by document type (the document types in turn belong to specified application objects) are displayed in the tree. The lower left part of the screen contains tab pages with the functions Detailed display, Document information (version string), Keywords and Storing. On the right-hand side of the screen, you can display a selected document in-place.
A bundled document structured by Class Name, Class Type and object Key. We can add additional attributes for document, including key word, title, description.
To save and get file programmatically, here are the codes.
I split them into two program, store document and get document. Program to get and display document can be found in next post.
Program to store document:
REPORT ZAALGAL0002 NO STANDARD PAGE HEADING.
* Store document in BDN
* -- connection table and the internal structure of the ITAB
DATA: BEGIN OF i_bds_conn OCCURS 10. " ITAB for the actual
INCLUDE STRUCTURE bdn_con. " document
DATA: objecttext LIKE toasp-objecttext,
objecttext2 LIKE toasd-objecttext,
objecttext3 LIKE toasr-objecttext,
ntext LIKE tojtt-ntext,
END OF i_bds_conn.
DATA: BEGIN OF bds_doctype_list OCCURS 10,
mandt TYPE mandt,
classname LIKE bapibds01-classname,
contrep LIKE i_bds_conn-contrep,
docuclass LIKE i_bds_conn-docuclass,
docuclass_text LIKE toasd-objecttext,
doc_type LIKE i_bds_conn-doc_type,
doc_type_text LIKE toasp-objecttext,
appl_type LIKE toadd-appl_type,
appl_type_text(50) TYPE c,
standard LIKE toadv-standard,
check_box LIKE toadv-standard,
END OF bds_doctype_list.
DATA: file_extension LIKE toadd-doc_type, " file-extension
i_files LIKE bapifiles OCCURS 1 WITH HEADER LINE,
i_signature LIKE bapisignat OCCURS 1 WITH HEADER LINE,
logical_system LIKE bds_conn00-log_system.
PARAMETERS: p_class LIKE bdn_con-classname OBLIGATORY,
p_objct LIKE bdn_con-objkey OBLIGATORY,
p_descr LIKE bdn_con-descript OBLIGATORY.
start-of-selection.
PERFORM create_doc_via_file.
*&---------------------------------------------------------------------*
*& Form CREATE_DOC_VIA_FILE
*&---------------------------------------------------------------------*
* create a new document via file
*----------------------------------------------------------------------*
FORM create_doc_via_file.
* -- data declaration ------------------------------------------------ *
DATA: classname_select LIKE bdn_con-classname,
classtype_select LIKE bdn_con-classtype,
objkey_select LIKE bdn_con-objkey,
mask(20) TYPE c,
answer TYPE c,
mimetype LIKE toadd-mimetype,
i_toadd LIKE toadd,
filename_all LIKE sapb-sapfiles,
file_path LIKE sapb-sapfiles,
file_path_memory(250) TYPE c, " path für SAP memory
file_path_length TYPE i, " length of the file_path
file_name LIKE sapb-sapfiles.
classname_select = p_class.
classtype_select = 'OT'.
objkey_select = p_objct.
GET PARAMETER ID 'OAP' FIELD file_path.
IF sy-subrc <> 0. " no file_path found.
file_path = space.
ENDIF.
CONCATENATE ',*.' '*' ',*.' '*' '.' INTO mask.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = file_path
mask = mask
mode = 'O'
title = 'Select File to upload'
IMPORTING
filename = filename_all
EXCEPTIONS
inv_winsys = 01
no_batch = 02
selection_cancel = 03
selection_error = 04.
IF sy-subrc = 3.
MESSAGE s012(sbds). " cancel file selection
EXIT.
ELSEIF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE e011(sbds). " error during file selection
ENDIF.
* -- split filename -- *
PERFORM split_path(oaall) USING filename_all file_path file_name.
* -- set new file_path to SAP memory -- *
file_path_length = strlen( file_path ).
IF file_path <> space AND file_path_length < file_path_memory =" file_path." file_path_memory =" space." file_extension =" space."> if no docuclass is found from the document
* -> default docuclass from the doctype!
file_extension = bds_doctype_list-docuclass.
ENDIF.
* -- get the mimetype of the docuclass -- *
PERFORM mimetype_get(oaall) USING file_extension
CHANGING i_toadd.
MOVE i_toadd-mimetype TO mimetype.
* -- fill file and signature structure -- *
CLEAR: i_files, i_signature.
REFRESH : i_files, i_signature.
i_files-doc_count = 1.
i_files-directory = file_path.
i_files-filename = file_name.
i_files-mimetype = mimetype.
APPEND i_files.
i_signature-doc_count = 1.
i_signature-prop_name = 'BDS_DOCUMENTCLASS'.
i_signature-prop_value = file_extension.
APPEND i_signature.
i_signature-prop_name = 'BDS_CONTREP'.
IF bds_doctype_list-contrep = space.
i_signature-prop_value = ' '. "#EC NOTEXT
ELSE.
i_signature-prop_value = bds_doctype_list-contrep.
ENDIF.
APPEND i_signature.
i_signature-prop_name = 'BDS_DOCUMENTTYPE'.
i_signature-prop_value = bds_doctype_list-doc_type.
APPEND i_signature.
i_signature-prop_name = 'DESCRIPTION'.
i_signature-prop_value = p_descr.
APPEND i_signature.
i_signature-prop_name = 'LANGUAGE'.
i_signature-prop_value = sy-langu.
APPEND i_signature.
* -- create new document via KPro -- *
CALL FUNCTION 'BDS_BUSINESSDOCUMENT_CREATEF'
EXPORTING
logical_system = logical_system
classname = classname_select
classtype = classtype_select
client = sy-mandt
object_key = objkey_select
TABLES
files = i_files
signature = i_signature
EXCEPTIONS
internal_error = 1
OTHERS = 2.
WRITE:/ 'sy-subrc:',sy-subrc.
ENDFORM. " CREATE_DOC_VIA_FILE
*&---------------------------------------------------------------------*
*& Form GET_FILE_EXTENSION
*&---------------------------------------------------------------------*
* try to get the extension of the uploaded file
*----------------------------------------------------------------------*
FORM get_file_extension USING file_name file_extension.
* -- data declaration ------------------------------------------------ *
DATA: length TYPE i,
single_c TYPE c.
* -------------------------------------------------------------------- *
CLEAR: single_c.
length = strlen( file_name ).
IF length > 0.
WHILE length > 0.
single_c = file_name+length(1).
IF single_c CO '.'.
length = length + 1.
EXIT.
ELSE.
length = length - 1.
ENDIF.
ENDWHILE.
IF length > 0.
file_extension = file_name+length.
ELSE.
file_extension = space.
ENDIF.
ELSE.
file_extension = space.
ENDIF.
IF file_extension <> space.
SET LOCALE LANGUAGE sy-langu.
TRANSLATE file_extension TO UPPER CASE. "#EC TRANSLANG
SET LOCALE LANGUAGE space.
ENDIF.
ENDFORM. " GET_FILE_EXTENSION