Professional Documents
Culture Documents
ENDCASE
This structure i_s_rkb1d has all details regarding the query like query tech name,
data target, etc.
Thereby, i_s_rkb1d-infocube will contain the data target for each query.
CASE i_s_rkb1d-infocube.
WHEN 'ZPP_DS06'.
* Fields to read
g_t_chanm-mode = rrke_c_mode-read.
g_t_chanm = 'ZCRPDT'.
APPEND g_t_chanm to e_t_chanm.
* Fields to write
g_t_chanm-mode = rrke_c_mode-no_selection.
g_t_chanm-chanm = 'ZCRPDTCLC'.
APPEND g_t_chanm to e_t_chanm.
ENDCASE.
We check the info cube attribute for the corresponding data target related to ou
r query.
rrke_c_mode is the structure that defines the mode of access for each IO (read mod
e, write mode).
g_t_chanm is the structure that will hold the name of characteristics that will be
used
g_t_kyfnm is the structure that will hold the name of key figures that will be use
d
In our example, we use only characteristics and hence only g_t_kyfnm structure.
The rest of the code should be self-explanatory.
For each new object, you assign its tech name to g_t_chanm_chanm object and append
it to e_t_chanm which is the output structure.
Similarly for key figures, e_t_kyfnm is the output structure.However for key figur
es, there is no structure to set the mode of access (mode of access read/write b
y default).
Another example to drive the point home:
* Characteristics and Units
g_t_chanm-mode = rrke_c_mode-read.
g_t_chanm-chanm = '0MATERIAL'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = '0PLANT'. append g_t_chanm to e_t_chanm.
g_t_chanm-mode = rrke_c_mode-no_selection.
g_t_chanm-chanm = 'PR_ID1'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = 'PR_ID2'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = 'PR_YEAR1'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = 'PR_YEAR2'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = 'PR_CURR1'. append g_t_chanm to e_t_chanm.
g_t_chanm-chanm = 'PR_CURR2'. append g_t_chanm to e_t_chanm.
* Key Figures
append '0QUANT_B' to e_t_kyfnm.
append 'AMOUNT1' to e_t_kyfnm.
append 'AMOUNT2' to e_t_kyfnm.
For g_t_kyfnm we need not set any mode.
Step 5: Writing the logic for virtual char/KF
Go to ZXRSRZZZ module in ABAP editor (tcode se38)
Here, create a new form for the data target being used.
Form name should be begin with USER_ followed by the data targets name.
C_S_DATE is the structure that would hold the data in the query.
To access the IOs in the code, we have to create field symbols that act as alias
es.
Then the global variables created are associated to these aliases using the ASSI
GN statement.
The rest of the code involves the implementation logic as in the snippet below.
FORM USER_ZPP_DS06 USING I_S_RKB1D TYPE RSR_S_RKB1D
CHANGING C_S_DATE TYPE ANY.
DATA: L_DATE TYPE SCAL-DATE.
DATA: L_WEEK TYPE SCAL-WEEK.
CONSTANTS: PAST_DUE(2) TYPE C VALUE 'PD'.
FIELD-SYMBOLS: , .
ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDT OF STRUCTURE C_S_DATE TO .
ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDTCLC OF STRUCTURE C_S_DATE TO .
L_DATE = SY-DATUM. "Today's Date
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = L_DATE
IMPORTING
WEEK = L_WEEK.
IF L_WEEK GT . "If Current Week is greater than Revised Promise Date, Calc_Date
holds "PD"
= PAST_DUE.
ELSE. "Calc_Date holds Revised Promise Date
= .
ENDIF.
ENDFORM.
Overall Program Flow for Calc Date
ZXRSRTOP
Data:
g_pos_ZPP_DS06_ZCRPDTCLC TYPE I,
g_pos_ZPP_DS06_ZCRPDT TYPE I.
ZXRSRU02
CASE i_s_rkb1d-infocube.
WHEN 'ZPP_DS06'.
* Fields to read
g_t_chanm-mode = rrke_c_mode-read.
g_t_chanm = 'ZCRPDT'.
APPEND g_t_chanm to e_t_chanm.
* Fields to write
g_t_chanm-mode = rrke_c_mode-no_selection.
g_t_chanm-chanm = 'ZCRPDTCLC'.
APPEND g_t_chanm to e_t_chanm.
ENDCASE.
ZXRSRZZZ
FORM USER_ZPP_DS06 USING I_S_RKB1D TYPE RSR_S_RKB1D
CHANGING C_S_DATE TYPE ANY.
DATA: L_DATE TYPE SCAL-DATE.
DATA: L_WEEK TYPE SCAL-WEEK.
CONSTANTS: PAST_DUE(2) TYPE C VALUE 'PD'.
FIELD-SYMBOLS: , .
ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDT OF STRUCTURE C_S_DATE TO .
ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDTCLC OF STRUCTURE C_S_DATE TO .
L_DATE = SY-DATUM. "Today's Date
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = L_DATE
IMPORTING
WEEK = L_WEEK.
IF L_WEEK GT . "If Current Week is greater than Revised Promise Date, Calc_Date
holds "PD"
= PAST_DUE.
ELSE. "Calc_Date holds Revised Promise Date
= .
ENDIF.
ENDFORM.
0 c