Tag Archives: abap

Process Chain FM API

RSPC_API_GET_CHAINS (Popup to select Process Chain)

RSPC_CHAIN_START (To start Process Chain of type API)

Sample program with PC selection and scheduling

REPORT ZBW_PC_MANAGER.

data: l_t_chains type standard table of RSPCCHAINT.
data: l_s_chains type RSPCCHAINT.
data: l_logid type rspc_logid.

CALL FUNCTION ‘RSPC_API_GET_CHAINS’
EXPORTING
I_WITH_DIALOG = ‘X’
* I_SEL_CHAIN =
* I_SEL_TXTLG =
TABLES
E_T_CHAINS = l_t_chains
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at l_t_chains into l_s_chains.
CALL FUNCTION ‘RSPC_CHAIN_START’
EXPORTING
I_CHAIN = l_s_chains-chain_id
* I_T_VARIABLES =
* I_SYNCHRONOUS =
* I_SIMULATE =
I_NOPLAN = ‘W’
* I_DONT_WAIT =
IMPORTING
E_LOGID = l_logid

Get size of database table via ABAP

Check program Check program RSTABLESIZE
or following code.

Update for BW74: FM ‘EM_GET_NUMBER_OF_ENTRIES’ import parameter has changed. see new code below.

Code up to BW 73

REPORT ZTEST_ILESH.

TABLES : DD02L.

SELECT-OPTIONS : S_TABLES FOR DD02L-TABNAME.

DATA : GT_TABROWS LIKE STANDARD TABLE OF DDCDIM,
       WA_TABROWS LIKE DDCDIM.

SELECT TABNAME
  FROM DD02L
  INTO CORRESPONDING FIELDS OF TABLE GT_TABROWS
  WHERE TABNAME IN S_TABLES.

CALL FUNCTION 'EM_GET_NUMBER_OF_ENTRIES'
  TABLES
    IT_TABLES = GT_TABROWS.

LOOP AT GT_TABROWS INTO WA_TABROWS.
  WRITE : / WA_TABROWS-TABNAME , WA_TABROWS-TABROWS.
ENDLOOP.

Code from BW74

Download – PROG_ZBC_CHECK_SYSTEM_TABLES_74.slnk] – 1.3 kB – 277   downloads

REPORT  ZBC_CHECK_SYSTEM_TABLES.

TABLES : DD02L.

SELECT-OPTIONS : S_TABLES FOR DD02L-TABNAME.

DATA : GT_TABROWS LIKE STANDARD TABLE OF DDCDIM,
       WA_TABROWS LIKE DDCDIM.

SELECT TABNAME
  FROM DD02L
  INTO CORRESPONDING FIELDS OF TABLE GT_TABROWS
  WHERE TABNAME IN S_TABLES.

CALL FUNCTION 'EM_GET_NUMBER_OF_ENTRIES'
  TABLES
    IT_TABLES = GT_TABROWS.

LOOP AT GT_TABROWS INTO WA_TABROWS.
  WRITE : / WA_TABROWS-TABNAME , WA_TABROWS-TABROWS.
ENDLOOP.

BEx Variables – Customer Exit related information

Article on performance improvements in ZXRSRU01 via use of EXPORT / IMPORT
Customer Exit variable warning Initial RANGE-LOW for customer exit variable corrected to #
This warning occurs if you set the LOW value to initial for a customer exit variable => instead you should use value ‘#’.

How to work with i_step = 3.
In this step there is no i_vnam info. But you can restrict the processing by calling query, by doing a CASE / ENDCASE on I_S_RKB1D-COMPID.

Article on setting up separate classes per BEx Variable and stop coding directly in ZXRSU01
http://www.biportal.org/Resources/Documents/BEx%20User%20Exit%20Variables.pdf

BI-Tools framework for BEx-Exit variables – Another class based apporoach to BEx Variable User Exits

REFX Contract Index Adjustment Data Extraction

The program below lists all the indexations that have occurred for a REFX lease contracts. ( For contracts that have not had or will never have any indexations, some info is available in table VIAJSEPCINDX (fields INDEXSERIES and INDEXBASEYEAR) )

For a given contract ID it derives the INTRENO (internal object ID).

The INTRENO is used to get all relevant records in VIAJRECORD. The records that correspond to past indexations have a status 3 in field ADJMDRECORDSTAT (‘Adjustment Complete’).
Other useful info => ADJMFROMOLD and ADJMFROMCALC (previous index date and index adjustement date)

Each record in VIAJRECORD is linked to a record in VIAJRECINDX via PROCESSGUID + INTRENO.

In VIAJRECINDX you can retrieve INDEXSERIES/INDEXBASEYEAR + ADJMINDEXBASE (index value at adjustement date) and FIRSTINDEXBASE (reference index at initial date of index calculations).

The program can be downloaded in SAPLINK format here


*&———————————————————————*
*& Report ZREFX_CNT_INDX_DATA
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT zrefx_cnt_indx_data.
DATA:
ls_viajrecindx TYPE viajrecindx,
ls_viajrecord TYPE viajrecord,
lt_viajrecindx TYPE TABLE OF viajrecindx,
lt_viajrecord TYPE TABLE OF viajrecord.

DATA:
lr_contrtype TYPE RANGE OF recncontracttype,
lrs_contrtype LIKE LINE OF lr_contrtype.

DATA: l_bukrs TYPE bukrs.
SELECT-OPTIONS: s_bukrs FOR l_bukrs.
DATA: l_reccnr TYPE recnnumber.
SELECT-OPTIONS: s_recnnr FOR l_reccnr.

DATA:
ls_contract TYPE recn_contract,
lt_rnsim TYPE re_t_renewal_sim,
ls_rnsim TYPE retm_renewal_sim.

“Limit to ZRDD, ZEXT and ZRIN
lrs_contrtype-sign = ‘I’.
lrs_contrtype-option = ‘EQ’.
lrs_contrtype-low = ‘ZRDD’.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = ‘ZRIN’.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = ‘ZEXT’.
APPEND lrs_contrtype TO lr_contrtype.
SELECT * FROM vicncn INTO ls_contract
WHERE bukrs IN s_bukrs
AND recnnr IN s_recnnr
AND recntype IN lr_contrtype.

REFRESH lt_viajrecord.
REFRESH lt_viajrecindx.

SELECT * FROM viajrecord
INTO TABLE lt_viajrecord
WHERE adjmdrecordstat = ‘3’
AND intreno = ls_contract-intreno.

SELECT * FROM viajrecindx
INTO TABLE lt_viajrecindx
FOR ALL ENTRIES IN lt_viajrecord
WHERE processguid = lt_viajrecord-processguid
and intreno = lt_viajrecord-intreno.

LOOP AT lt_viajrecord INTO ls_viajrecord.
read table lt_viajrecindx into ls_viajrecindx
with key processguid = ls_viajrecord-processguid
intreno = ls_viajrecord-intreno.
NEW-LINE.
WRITE: ls_contract-recnnr, ‘:’, ls_viajrecindx-firstindexbase ,’:’, ls_viajrecindx-indexseries ,’:’, ls_viajrecindx-indexbaseyear , ‘:’, ls_viajrecord-adjmfromold, ‘:’,’:’, ls_viajrecord-adjmfromcalc, ‘:’, ls_viajrecindx-adjmindexbase.
ENDLOOP.
ENDSELECT.

BEX Workbook Size Analysis report

One element influencing the performance of a BEx Workbook is its size. Each time you open a BEX Workbook from your BEx Analyzer, the excel file corresponding to the BEx Workbook is retrieved from the BW servers (it is stored as blob format in table RSRWBSTORE) and transferred to the front end.

Thus, before even doing a first refresh, there might be a perceivable delay due to the workbook transfer.

You can monitor the sizes of all the workbooks in your BW system with the following report available in Saplink format:

Download – PROG_ZBI_WORKBOOK_SIZES.slnk –  2.4 kB – 256   downloads

The size displayed by the report is in lines in table RSRBWSTORE. The real size is about 2000kb multiplied by the number of lines.

(Note: The BEx Workbooks are also stored in temp directory on the PC when executed. I do not know however if this means that the entire workbook is not always transferred on opening. If you have any info on the subject, please leave a comment.)

The below code also displays the French and Dutch workbook title.  (Just change the F and N to E and D to have it in English and German for instance.

*&---------------------------------------------------------------------*
*& Report  ZBI_WORKBOOK_SIZES
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zbi_workbook_sizes.

TYPES:
   BEGIN OF ty_output,
     workbookid TYPE rsrwbindex-workbookid,
     lines TYPE i,
     title_n TYPE rsrwbindext-title,
     title_f TYPE rsrwbindext-title,
   END OF ty_output.

DATA:
      l_lines TYPE i,
      lt_output TYPE TABLE OF ty_output,
      ls_output TYPE ty_output,
      ls_rsrwbindex TYPE rsrwbindex,
      ls_rsrwbindext_n TYPE rsrwbindext,
      ls_rsrwbindext_f TYPE rsrwbindext,
      lt_rsrwbindex TYPE TABLE OF rsrwbindex.

" Selection parameters
SELECT-OPTIONS s_wbk FOR ls_rsrwbindex-workbookid.

" Get list of workbooks
SELECT * FROM rsrwbindex INTO TABLE lt_rsrwbindex
  WHERE workbookid IN s_wbk
    AND objvers = 'A'.

LOOP AT lt_rsrwbindex INTO ls_rsrwbindex.
  SELECT MAX( linenumber ) FROM rsrwbstore INTO l_lines
    WHERE objvers = 'A'
      AND workbookid = ls_rsrwbindex-workbookid.
  SELECT SINGLE * FROM rsrwbindext INTO ls_rsrwbindext_n
    WHERE objvers = 'A'
     AND langu = 'N'
     AND  workbookid = ls_rsrwbindex-workbookid.

  SELECT SINGLE * FROM rsrwbindext INTO ls_rsrwbindext_f
WHERE objvers = 'A'
 AND langu = 'F'
 AND  workbookid = ls_rsrwbindex-workbookid.
  ls_output-workbookid = ls_rsrwbindex-workbookid.
  ls_output-lines = l_lines.
  ls_output-title_n = ls_rsrwbindext_n-title.
  ls_output-title_f = ls_rsrwbindext_f-title.
  APPEND ls_output TO lt_output.
ENDLOOP.
SORT lt_output BY lines DESCENDING.
LOOP AT lt_output INTO ls_output.
  WRITE:  ls_output-title_n, ls_output-title_f, ls_output-lines, ls_output-workbookid .
  NEW-LINE.
ENDLOOP.

Get REFX contract break dates via ABAP

In SAP REFX, only the first contract end date is stored in the contract master data. All the next possible break dates are linked to renewal rules. In transaction RE80 or RECN you can simulate future renewals to see all possible future break dates.

Below is a small program that fills an internal table with the same information as the one provided by the simulation button. The program uses a FM that performs the actions that are behind the contract renewal simulate button.

Download – NUGG_CONTRACT_BREAK_DATES.nugg – 6.3 kB – 347   downloads

Function Module

FUNCTION zrefx_cnt_break_get_list.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_RECNNR) TYPE RECNNUMBER
*" REFERENCE(I_BUKRS) TYPE BUKRS
*" EXPORTING
*" REFERENCE(ET_RNSIM) TYPE RE_T_RENEWAL_SIM
*" EXCEPTIONS
*" NOT_FOUND
*"----------------------------------------------------------------------
DATA:
lo_rn_mngr TYPE REF TO if_recn_renewal_mngr,
lo_rn_rule_mngr TYPE REF TO if_retm_renewal_rule_mngr,
ls_contract TYPE recn_contract,
lo_contract TYPE REF TO if_recn_contract.

" Setup a if_recn_contract object reference
" See FORM recontract_package_get in INCLUDE LREIS_MASTERDATA_EXTRACTIONF01
SELECT SINGLE * FROM vicncn INTO CORRESPONDING FIELDS OF ls_contract
WHERE bukrs = i_bukrs
AND recnnr = i_recnnr.

* get object
CALL METHOD cf_recn_contract=>find_by_detail
EXPORTING
is_detail = ls_contract
RECEIVING
ro_instance = lo_contract
EXCEPTIONS
OTHERS = 0.
" See PERFORM cn_next_end_get in the include file LREIS_MASTERDATA_EXTRACTIONF02
IF lo_contract IS BOUND.
lo_rn_mngr = lo_contract->get_renewal_mngr( ).
CALL METHOD lo_rn_mngr->get_renewal_rule_mngr
RECEIVING
ro_instance = lo_rn_rule_mngr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.

CALL METHOD lo_rn_rule_mngr->set_sim_defaults
EXPORTING
if_sim_reject_all = abap_true.

CALL METHOD lo_rn_rule_mngr->calc_date_list
EXPORTING
if_simulate = abap_true
IMPORTING
et_rnsim = et_rnsim
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
ENDIF.
ENDFUNCTION.

Program

*&---------------------------------------------------------------------*
*& Report Z_TEST_CONTRACT_DATA
*&
*&---------------------------------------------------------------------*
*This report returns via ABAP, the break dates that can are obtained
*in transaction RE80 when displaying a contract

REPORT zrefx_cnt_break_data_test.

DATA:
lr_contrtype TYPE RANGE OF recncontracttype,
lrs_contrtype LIKE LINE OF lr_contrtype.

DATA: l_bukrs TYPE bukrs.
SELECT-OPTIONS: s_bukrs FOR l_bukrs.
DATA: l_reccnr TYPE recnnumber.
SELECT-OPTIONS: s_recnnr FOR l_reccnr.

DATA:
ls_contract TYPE recn_contract,
lt_rnsim TYPE re_t_renewal_sim,
ls_rnsim TYPE RETM_RENEWAL_SIM.

"Limit to ZRDD, ZEXT and ZRIN
lrs_contrtype-sign = 'I'.
lrs_contrtype-option = 'EQ'.
lrs_contrtype-low = 'ZRDD'.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = 'ZRIN'.
APPEND lrs_contrtype TO lr_contrtype.
lrs_contrtype-low = 'ZEXT'.
APPEND lrs_contrtype TO lr_contrtype.
SELECT * FROM vicncn INTO ls_contract
WHERE bukrs IN s_bukrs
AND recnnr IN s_recnnr
AND recntype IN lr_contrtype.
CALL FUNCTION 'ZREFX_CNT_BREAK_GET_LIST'
EXPORTING
i_recnnr = ls_contract-recnnr
i_bukrs = ls_contract-bukrs
IMPORTING
ET_RNSIM = lt_rnsim
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF sy-subrc = 1.
NEW-LINE.
WRITE: ls_contract-recnnr, ': No break'.
ELSEif sy-subrc > 1..
NEW-LINE.
WRITE: ls_contract-recnnr, ': Error'.
ELSE.
LOOP AT lt_rnsim INTO ls_rnsim.
NEW-LINE.
WRITE: ls_contract-recnnr, ':', ls_rnsim-RNEXTDATE, ':', ls_rnsim-RNNOTDATE.
ENDLOOP.
ENDIF.

ENDSELECT.