ABAP return to the initial selection screen after a write - crud

I am new to ABAP. I have created a report that basically handles the CRUD for a database already built with function modules. It has multiple selection-screens for every function. Is there anyway to perform a READ and print it on the screen with 'write' and after that go back to the initial Selection-screen?
DATA: lv_response1 TYPE flag,
lv_response2 TYPE flag,
lv_response3 TYPE flag.
SELECTION-SCREEN BEGIN OF SCREEN 100.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-t01.
PARAMETERS: s1 RADIOBUTTON GROUP g1,
s2 RADIOBUTTON GROUP g1,
s3 RADIOBUTTON GROUP g1,
s4 RADIOBUTTON GROUP g1,
s5 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN BEGIN OF SCREEN 200.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-t02.
PARAMETERS: p_skill TYPE Z0B_SKILL_ACR,
p_skills type Z0B_SKILL_SUBDOM_ACR,
p_skilld TYPE Z0B_SKILL_NAME,
p_skilll TYPE z0b_linguistic.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.
SELECTION-SCREEN BEGIN OF SCREEN 300.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-t03.
PARAMETERS: p_skid TYPE z0b_skillid,
p_all TYPE flag.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.
SELECTION-SCREEN BEGIN OF SCREEN 400.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-t04.
PARAMETERS: p_skacr TYPE z0b_skill_acr,
p_skdesc TYPE z0b_skill_name.
SELECTION-SCREEN END OF BLOCK B4.
SELECTION-SCREEN END OF SCREEN 400.
SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-t05.
PARAMETERS p_dskid TYPE z0b_skillid.
SELECTION-SCREEN END OF BLOCK B5.
SELECTION-SCREEN END OF SCREEN 500.
CALL SELECTION-SCREEN 100.
IF s1 = 'X'.
"Create skill
CALL SELECTION-SCREEN 200.
CALL FUNCTION 'Z0B_ADD_NEW_SKILL'
EXPORTING
IV_SKILL_ACR = p_skill
IV_SKILL_SUBDOM = p_skills
IV_SKILL_DESC = P_skilld
IV_SKILL_LINGUISTIC = p_skilll
IMPORTING
EV_CHECK_SUBDOM = lv_response1
EV_CHECK_SKILL_ACR_A = lv_response2
EV_CHECK = lv_response3.
IF lv_response1 eq 0.
WRITE:/ 'Subdomain does not exist.'.
ENDIF.
IF lv_response2 eq 1.
WRITE:/ 'Skill already exists.'.
ENDIF.
IF lv_response3 eq 0.
WRITE:/ 'Database error.'.
ENDIF.
IF lv_response1 eq 1 AND lv_response2 eq 0 AND lv_response3 eq 1.
WRITE:/ 'Skill created successfully.'.
ENDIF.
EXIT.
ENDIF.
***********************************************************************************************************
IF s2 = 'X'.
"Read skill
CALL SELECTION-SCREEN 300.
data: lt_skills type Z0B_MY_SKILLS_T,
ls_skills type z0b_skills_t.
IF p_all is not INITIAL.
CALL FUNCTION 'Z0B_GET_ALL_SKILLS'
IMPORTING
ET_NONLINGUISTIC_SKILLS = lt_skills
EV_CHECK = lv_response2
* EXCEPTIONS
* NO_SKILL = 1
* OTHERS = 2
.
write 'Non-linguistic skills'.
LOOP AT lt_skills into ls_skills.
write: / ls_skills-skillid, ls_skills-skill_text, ls_skills-skill_acr.
ENDLOOP.
CALL FUNCTION 'Z0B_GET_LANG'
IMPORTING
ET_LINGUISTIC_SKILLS = lt_skills
EV_CHECK = lv_response3
* EXCEPTIONS
* NO_SKILL = 1
* OTHERS = 2
.
write:/.
write:/ 'Linguistic skills'.
LOOP AT lt_skills into ls_skills.
write: / ls_skills-skillid, ls_skills-skill_text, ls_skills-skill_acr.
ENDLOOP.
IF lv_response3 eq 0 and lv_response2 eq 0.
WRITE:/ 'No entries.'.
endif.
exit.
ENDIF.
CALL FUNCTION 'Z0B_READ_MASTERDATA_SKILL'
EXPORTING
IV_SKILLID = p_skid
IMPORTING
ET_SKILLS = lt_skills
EV_CHECK = lv_response3
* EXCEPTIONS
* NO_DATA = 1
* OTHERS = 2.
IF lv_response3 eq 0.
WRITE:/ 'Database error.'.
ENDIF.
LOOP AT lt_skills into ls_skills.
write: / ls_skills-skill_text, ls_skills-skill_acr.
ENDLOOP.
endif.
***********************************************************************************
IF s3 = 'X'.
" Update a skill
CALL SELECTION-SCREEN 400.
CALL FUNCTION 'Z0B_MODIFY_SKILL'
EXPORTING
IV_SKILLS_ACR = p_skacr
IV_SKILLS_DESC = p_skdesc
IMPORTING
EV_CHECK = lv_response1
* EXCEPTIONS
* NO_SKILL = 1
* NO_DATA = 2
* NO_UPDATE = 3
* OTHERS = 4
.
IF lv_response1 = 0.
WRITE 'Failed.'.
else.
write 'Skill modified successfully'.
ENDIF.
ENDIF.
***********************************************************************************
IF s4 = 'X'.
CALL SELECTION-SCREEN 500.
CALL FUNCTION 'Z0B_DELETE_SKILL'
EXPORTING
IV_SKILLS_ID = p_dskid
IMPORTING
EV_CHECK = lv_response1
* EXCEPTIONS
* NO_SKILL = 1
* NO_MOVE = 2
* NO_DELETE_1 = 3
* NO_DELETE_2 = 4
* SKILL_USED = 5
* OTHERS = 6
.
IF lv_response1 = 0.
WRITE 'Failed.'.
else.
write 'Skill deleted successfully'.
ENDIF.
ENDIF.

Remove the SELECTION-SCREEN BEGIN/END OF SCREEN 100. That way what was screen 100 will become the standard selection screen (1000), then there also is no need to call it anymore. So, replace the CALL SELECTION-SCREEN 100 with START-OF-SELECTION. With those changes you will get back to the selection screen when you press the back arrow on the output screen.
You might also have to remove the EXIT.

Related

Display data fields based on checkbox selection in SAP ABAP

Below is simple code where I want to display location based on checkbox selection.
Eg: id p_pune is selected at seletion screen then after WRITE command my output should be as below
EMPID NAME LOCATION
1 A PUNE
Code:
TYPES: BEGIN OF ty_emp,
empid TYPE i,
name TYPE char5,
location TYPE char6,
END OF ty_emp.
DATA: wa_emp TYPE ty_emp,
it_emp TYPE TABLE OF ty_emp.
DATA: gd_ucomm TYPE sy-ucomm.
wa_emp-empid = 1.
wa_emp-name = 'A'.
wa_emp-location = 'Pune'.
append wa_emp to it_emp.
CLEAR wa_emp.
wa_emp-empid = 2.
wa_emp-name = 'B'.
wa_emp-location = 'Mumbai'.
append wa_emp to it_emp.
CLEAR wa_emp.
wa_emp-empid = 3.
wa_emp-name = 'C'.
wa_emp-location = 'Delhi'.
append wa_emp to it_emp.
CLEAR wa_emp.
wa_emp-empid = 4.
wa_emp-name = 'D'.
wa_emp-location = 'Noida'.
append wa_emp to it_emp.
CLEAR wa_emp.
PARAMETERS: p_pune AS CHECKBOX USER-COMMAND c1,
p_mumbai AS CHECKBOX USER-COMMAND c2,
p_delhi AS CHECKBOX USER-COMMAND c3,
p_noida AS CHECKBOX USER-COMMAND c4.
You can try this:
IF p_pune = abap_true.
READ TABLE it_emp INTO wa_emp INDEX '1'.
WRITE:/ wa_emp-empid, wa_emp-name, wa_emp-location.
ENDIF.
IF p_mumbai = abap_true.
READ TABLE it_emp INTO wa_emp INDEX '2'.
WRITE:/ wa_emp-empid, wa_emp-name, wa_emp-location.
ENDIF.
IF p_delhi = abap_true.
READ TABLE it_emp INTO wa_emp INDEX '3'.
WRITE:/ wa_emp-empid, wa_emp-name, wa_emp-location.
ENDIF.
IF p_noida = abap_true.
READ TABLE it_emp INTO wa_emp INDEX '4'.
WRITE:/ wa_emp-empid, wa_emp-name, wa_emp-location.
ENDIF.
When you check multiple checkboxes, it will display multiple locations.
If you want to display only one location, I suggest you use RADIO BUTTON instead of CHECKBOX.
You could convert the boolean values of the parameters to a location, using the COND statement. Then you can loop over the internal table with LOOP AT and use it's WHERE condition to filter out the location you need.
TYPES:
BEGIN OF employee,
empid TYPE i,
name TYPE char5,
location TYPE char6,
END OF employee,
employees TYPE STANDARD TABLE OF employee WITH EMPTY KEY.
DATA(employees) = VALUE employees(
( empid = 1 name = 'A' location = 'Pune' )
( empid = 2 name = 'B' location = 'Mumbai' )
( empid = 3 name = 'C' location = 'Dehli' )
( empid = 4 name = 'D' location = 'Noida' )
).
PARAMETERS: pune AS CHECKBOX,
mumbai AS CHECKBOX,
dehli AS CHECKBOX,
noida AS CHECKBOX.
START-OF-SELECTION.
DATA(wanted_location) = COND char6(
WHEN pune = abap_true THEN 'Pune'
WHEN mumbai = abap_true THEN 'Mumbai'
WHEN dehli = abap_true THEN 'Dehli'
WHEN noida = abap_true THEN 'Noida'
).
LOOP AT employees INTO DATA(employee)
WHERE location = wanted_location.
WRITE:
employee-empid,
employee-location,
employee-name.
NEW-LINE.
ENDLOOP.

abap count similar row values

IF ls_th_sum_lab_ndt IS not INITIAL.
ls_th_sum_lab_ndt-ndt_flag = 'X'.
ls_th_sum_lab_ndt-zwc_cat = 'NDT'.
if there are more than 2 zwc_cat that equal to NDT change the other one to MH
APPEND ls_th_sum_lab_ndt TO gt_th_sum_lab_ndt.
ENDIF.
Basically what I want to do:
Update ls_th_sum_lab_ndt-zwc_cat=MH if ls_th_sum_lab_ndt-zwc_cat="NDT" >2 set second row to MH
Thank You in Advance!
Try this:
DATA: lv_count type i,
lv_index type sy-tabix.
...
LOOP AT gt_th_sum_lab_ndt INTO ls_th_sum_lab_ndt WHERE zwc_cat = 'NDT'.
lv_count = lv_count + 1.
if lv_count >= 2.
lv_index = sy-tabix.
exit.
endif.
ENDLOOP.
CHECK lv_count >= 2.
READ TABLE gt_th_sum_lab_ndt INTO ls_th_sum_lab_ndt INDEX lv_index.
ls_th_sum_lab_ndt-zwc_cat = 'MH'.
MODIFY gt_th_sum_lab_ndt FROM ls_th_sum_lab_ndt INDEX lv_index.
Hope it helps.

Assign values to dynamic structure

Need idea on the below codes, on how to simplify. Codes below works good but is there a way I could enhance or shorten the codes making it dynamic?
TYPES: BEGIN OF lty_dates,
yesterday TYPE string,
today TYPE string,
tomorrow TYPE string,
END OF lty_dates.
DATA: it_table TYPE TABLE OF lty_dates.
DO 3 TIMES.
CASE lv_count.
WHEN 1.
it_table[ 1 ]-zyesterday = 'Result Yesterday'.
it_table[ 2 ]-zyesterday = 'Result Yesterday'.
it_table[ 3 ]-zyesterday = 'Result Yesterday'.
WHEN 2.
it_table[ 1 ]-ztoday = 'Result Today'.
it_table[ 2 ]-ztoday = 'Result today'.
it_table[ 3 ]-ztoday = 'Result Today'.
WHEN 3.
it_table[ 1 ]-ztommorrow = 'Result Tomorrow'.
it_table[ 2 ]-ztommorrow = 'Result Tomorrow'.
it_table[ 3 ]-ztommorrow = 'Result Tomorrow'.
ENDCASE.
lv_count = lv_count + 1.
ENDDO.
My idea is something like the below pseudocodes. I would not want to perform CASE multiple times specially instances if fields for it_table would reach 100 (fields).
DO 3 TIMES.
ASSIGN 'ZTODAY' TO <dynamic_fieldname>.
it_table[ 1 ]-<dynamic_fieldname> = <dynamic_result>.
it_table[ 2 ]-<dynamic_fieldname> = <dynamic_result>.
it_table[ 3 ]-<dynamic_fieldname> = <dynamic_result>.
ENDDO.
Please help or light me up on this.
You could use the command ASSIGN COMPONENT compname OF STRUCTURE structure TO <field_symbol>.
TYPES: BEGIN OF lty_dates,
yesterday TYPE string,
today TYPE string,
tomorrow TYPE string,
END OF lty_dates.
TYPES: BEGIN OF lty_result ,
fieldname TYPE fieldname,
result TYPE string,
END OF lty_result .
FIELD-SYMBOLS <data> TYPE any .
DATA: lt_table TYPE TABLE OF lty_dates,
lt_result TYPE TABLE OF lty_result.
lt_result = VALUE #( ( fieldname = 'yesterday'
result = 'Result Yesterday' )
( fieldname = 'today'
result = 'Result Today' )
( fieldname = 'tomorrow'
result = 'Result Tomorrow' ) ).
lt_table = VALUE #( ( ) ( ) ( ) ). " 3 empty lines
LOOP AT lt_table ASSIGNING FIELD-SYMBOL(<table>) .
LOOP AT lt_result ASSIGNING FIELD-SYMBOL(<result>) .
ASSIGN COMPONENT <result>-fieldname OF STRUCTURE <table> TO <data> .
<data> = <result>-result.
ENDLOOP .
ENDLOOP .
Actually, your code creates this result table:
YESTERDAY TODAY TOMORROW
Result Yesterday Result Today Result Tomorrow
Result Yesterday Result today Result Tomorrow
Result Yesterday Result Today Result Tomorrow
Why not to use macro for this? Macro can perfectly fulfill your needs:
FIELD-SYMBOLS: <fvalue> TYPE ANY.
DEFINE put_values.
ASSIGN COMPONENT &1 OF STRUCTURE &2 TO <fvalue>.
<fvalue> = &3.
END-OF-DEFINITION.
it_table = VALUE #( ( ) ( ) ( ) ).
LOOP AT it_table ASSIGNING FIELD-SYMBOL(<fs_tab>).
put_values 'yesterday' <fs_tab> 'Result Yesterday'.
put_values 'today' <fs_tab> 'Result Today'.
put_values 'tomorrow' <fs_tab> 'Result Tomorrow'.
ENDLOOP.
This will work if the number if the loop iterations are equal to lines of itab (as in your code).

How to return value to user from a Search Help Exit

I have a Search Help with many fields to be displayed to the user in order to apply values. I want to get 3 fields APOFASI, SKOPOS, KATDANL from the user.
In the CALLCONTROL-STEP = SELECT in the exit FM, I want to get these values in variables and then to make some selects and find another field APOFASISAP.
I am trying to pass back to the selection fields of the search help the field APOFASSISAP, but the APOFASI field seems to be blank.
The code is:
TYPES: BEGIN OF ty_apofasisap_tr,
apofasisap_tr TYPE zglk_sap_afopasi,
END OF ty_apofasisap_tr.
DATA: it_apofasisap_tr TYPE TABLE OF ty_apofasisap_tr,
wa_apofasisap_tr LIKE LINE OF it_apofasisap_tr.
DATA: lv_apofasi TYPE zglk_kyanr_ap,
lv_skopos TYPE zskopos,
lv_katdanl TYPE zsl_cat_dan,
lv_apofasisap_arx TYPE zglk_sap_afopasi.
lv_apofasi = wa_shlp_selopt-low.
ls_result-apofasi = ''.
IF lv_apofasi <> ''.
wa_shlp_selopt-low = ''.
MODIFY shlp-selopt FROM wa_shlp_selopt INDEX sy-tabix.
ENDIF.
READ TABLE shlp-selopt INTO wa_shlp_selopt WITH KEY shlpfield = 'SKOPOS'.
lv_skopos = wa_shlp_selopt-low.
READ TABLE shlp-selopt INTO wa_shlp_selopt WITH KEY shlpfield = 'KATDANL'.
lv_katdanl = wa_shlp_selopt-low.
SELECT SINGLE apofasisap INTO lv_apofasisap_arx
FROM zsl_glk_apof
WHERE apofasi = lv_apofasi.
SELECT * FROM zsl_glk_apof_tr
WHERE apofasisap_trp = lv_apofasisap_arx.
wa_apofasisap_tr-apofasisap_tr = zsl_glk_apof_tr-apofasisap_tr.
APPEND wa_apofasisap_tr TO it_apofasisap_tr.
ENDSELECT.
wa_shlp_selopt-shlpname = 'ZAPOF_TROP'.
wa_shlp_selopt-shlpfield = 'APOFASISAP'.
wa_shlp_selopt-sign = 'I'.
wa_shlp_selopt-option = 'EQ'.
wa_shlp_selopt-low = wa_apofasisap_tr-apofasisap_tr.
APPEND wa_shlp_selopt TO shlp-selopt.
This code does not replace/add the values to the appropriate fields.
Can someone help on this?
PS. Let me add another code that I wrote with the help of internet. It is in the STEP of DISPLAY.
IF callcontrol-step = 'DISP'.
TYPES: BEGIN OF ls_result,
apofasi LIKE zsl_glk_apof-apofasi,
apofasidate LIKE zsl_glk_apof-apofasidate,
apofasisap LIKE zsl_glk_apof-apofasisap,
apofasi_trp_x LIKE zsl_glk_apof-apofasi_trp_x,
apofasi_tr_x LIKE zsl_glk_apof-apofasi_tr_x,
fek LIKE zsl_glk_apof-fek,
katdanl LIKE zsl_glk_apof-katdanl,
reference LIKE zsl_glk_apof-reference,
skopos LIKE zsl_glk_apof-skopos,
thema LIKE zsl_glk_apof-thema,
type_desc LIKE zsl_glk_apof-type_desc,
ya_first LIKE zsl_glk_apof-ya_first,
END OF ls_result.
DATA: lt_result TYPE STANDARD TABLE OF ls_result.
CLEAR: lt_result, record_tab, record_tab[].
* Read the value that user gave
READ TABLE shlp-selopt INTO wa_shlp_selopt
WITH KEY shlpfield = 'APOFASI'.
lv_apofasi = wa_shlp_selopt-low.
IF lv_apofasi <> ''.
* Clear this value
wa_shlp_selopt-low = ''.
MODIFY shlp-selopt FROM wa_shlp_selopt INDEX sy-tabix.
ENDIF.
* Find the number starting APOFASISAP from the APOFASI text
SELECT SINGLE apofasisap INTO lv_apofasisap_arx
FROM zsl_glk_apof
WHERE apofasi = lv_apofasi.
IF sy-subrc = 0.
* Find the APOFASISAPs which changes the starting one and display the
*fields
SELECT a~apofasi a~apofasidate a~apofasisap
a~apofasi_tr_x a~apofasi_trp_x
a~thema a~fek a~reference a~ya_first
INTO CORRESPONDING FIELDS OF TABLE lt_result
FROM zsl_glk_apof AS a INNER JOIN zsl_glk_apof_tr AS b
ON a~apofasisap = b~apofasisap_tr
WHERE b~apofasisap_trp = lv_apofasisap_arx.
IF sy-subrc = 0.
*Pass them to display the result.
CALL FUNCTION 'F4UT_RESULTS_MAP'
EXPORTING
* SOURCE_STRUCTURE =
apply_restrictions = 'X'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_result
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 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.
ENDIF.
FREE lt_result.
ENDIF.
It says NO VALUES FOR THIS SELECTION. The table lt_result contains 11 records.
Thanks again.
I agree with the forespeakers, that provided code is a mess, from which nothing can be figured out.
First of all, use DISP event in SHELP FM exit, not SELECT.
Secondly, you fill the wrong table (or do not show us right filling in the snippet above). In order to pass values back to user you should modify a RECORD_TAB table.
Your code should look something like this (joined selections from zsl_glk_apof and zsl_glk_apof_tr tables):
CHECK callcontrol-step = 'DISP'.
DATA: ls_selopt TYPE ddshselopt. "loc str for shlp-selopt
DATA: BEGIN OF ls_record.
INCLUDE STRUCTURE seahlpres.
DATA: END OF ls_record.
DATA: lv_glk_apof_tr TYPE zsl_glk_apof_tr-apofasisap_tr.
LOOP AT shlp-selopt INTO ls_selopt.
* finding SKOPOS and KATDANL values
CASE ls_selopt-shlpfield.
WHEN 'SKOPOS'.
lv_skopos = ls_selopt-low.
WHEN 'KATDANL'.
lv_katdanl = ls_selopt-low.
WHEN OTHERS.
ENDCASE.
* doing smth
* finding some stuff from Z-tables
SELECT SINGLE tr~apofasisap_tr
FROM zsl_glk_apof AS ap
JOIN zsl_glk_apof_tr AS tr
ON ap~apofasisap = tr~apofasisap_trp
INTO lv_glk_apof_tr
WHERE ap~apofasi = lv_apofasi.
ENDLOOP.
* modify record_tab with the found value lv_glk_apof_tr
LOOP AT record_tab INTO ls_record.
ls_record-string+25(5) = lv_glk_apof_tr. "field shift should be based on your values
ENDLOOP.
Hello and thanks all for your valuable help.
Finally I did it as follow:
if callcontrol-step = 'SELECT'.
get parameter id 'ZAP' field p_apofasi.
get parameter id 'ZSK' field p_skopos.
get parameter id 'ZKATDANL' field p_katdanl.
select single apofasisap into lv_apofasisap_arx
from zsl_glk_apof
where apofasi = p_apofasi and
katdanl = p_katdanl and
skopos = p_skopos.
select * into corresponding fields of table it_apofasisap_tr
from zsl_glk_apof_tr
where apofasisap_trp = lv_apofasisap_arx.
* Display the results to the user
types: begin of ls_result,
apofasi like zsl_glk_apof-apofasi,
apofasidate like zsl_glk_apof-apofasidate,
apofasisap like zsl_glk_apof-apofasisap,
apofasi_trp_x like zsl_glk_apof-apofasi_trp_x,
apofasi_tr_x like zsl_glk_apof-apofasi_tr_x,
katdanl like zsl_glk_apof-katdanl,
skopos like zsl_glk_apof-skopos,
type_desc like zsl_glk_apof-type_desc,
end of ls_result.
data: lt_result type standard table of ls_result.
clear: lt_result, record_tab, record_tab[].
* Fill all the fields of the Search-Help with the data according to the
*selections of the user.
select apofasi apofasidate apofasisap
apofasi_tr_x apofasi_trp_x
katdanl skopos type_desc
into corresponding fields of table lt_result
from zsl_glk_apof
for all entries in it_apofasisap_tr
where apofasisap = it_apofasisap_tr-apofasisap_tr and
apofasi_tr_x = 'X'. "lv_apofasi_tr_x.
call function 'F4UT_RESULTS_MAP'
tables
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_result
changing
shlp = shlp
callcontrol = callcontrol
exceptions
illegal_structure = 1
others = 2.
if sy-subrc = 0.
callcontrol-step = 'DISP'.
else.
callcontrol-step = 'EXIT'.
endif.
endif.
Regards
Elias

SAP SLT into HANA not updating date field

I would like to SLT data into our HANA Data warehouse. That is the easy part, I can move data that is a one to one match (type 1 table). But I would like to make it type 2 and preserve history. I have the following code in the transform, and it will not populate the update field.
*&---------------------------------------------------------------------*
*& Include ZAUSP_SLT_TRANSFORM
*&---------------------------------------------------------------------*
STATICS lv_syn_name TYPE tabname.
DATA con_name TYPE dbcon_name.
DATA lv_timestamp TYPE timestampl.
FIELD-SYMBOLS <lv_operation> TYPE any.
CONCATENATE _mt_id ':R:R' INTO con_name.
ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_AUSP> TO <lv_operation>.
IF sy-subrc = 0 AND
<lv_operation> = 'D'.
IF lv_syn_name IS INITIAL.
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
GET TIME STAMP FIELD lv_timestamp.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET ZDELETE_FLAG = 'X'
ZUPD_DATETIME = lv_timestamp
WHERE mandt = <wa_s_AUSP>-mandt
AND objek = <wa_s_AUSP>-objek
AND atinn = <wa_s_AUSP>-atinn
AND atzhl = <wa_s_AUSP>-atzhl
AND mafid = <wa_s_AUSP>-mafid
AND klart = <wa_s_AUSP>-klart
AND adzhl = <wa_s_AUSP>-adzhl.
IF sy-subrc <> 0.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
skip_record.
ENDIF.
"Code for timestamp outside of delete.
IF lv_syn_name IS INITIAL.
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
GET TIME STAMP FIELD lv_timestamp.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET ZUPD_DATETIME = lv_timestamp "slt_update is the name in your slt strucure!
WHERE MANDT = <wa_s_AUSP>-MANDT "key_1 = pk of your table
AND OBJEK = <wa_s_AUSP>-OBJEK
AND ATINN = <wa_s_AUSP>-ATINN
AND ATZHL = <wa_s_AUSP>-ATZHL
AND MAFID = <wa_s_AUSP>-MAFID
AND KLART = <wa_s_AUSP>-KLART
AND ADZHL = <wa_s_AUSP>-ADZHL.
IF sy-subrc <> 0.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
Why don't the time field get updated for all rows inserted into target? When I try and set a break point to debug during replication, I get the following error:
So I click one, and get the following for each one:
So I go to SE38 and try to activate each one individually:
I did not write the code in these additional programs, and do not understand how they relate to the INCLUDE I wrote. I am left thinking the INCLUDE transform I wrote is not being executed due to the background programs not being active?
The below code resolved my issue.
STATICS lv_syn_name TYPE tabname.
DATA con_name TYPE dbcon_name.
DATA lv_timestamp TYPE timestampl.
FIELD-SYMBOLS <lv_operation> TYPE any.
FIELD-SYMBOLS: <lt_log_tab> TYPE table,
<ls_log_tab> TYPE any,
<lv_primary_key_1> TYPE any,
<lv_primary_key_2> TYPE any,
<lv_primary_key_3> TYPE any,
<lv_primary_key_4> TYPE any.
*
*
*
** get operation flag
ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_ausp> TO <lv_operation>.
*
*
IF sy-subrc = 0 AND
<lv_operation> = 'D'.
*
*
**** replication mode and record was deleted
IF lv_syn_name IS INITIAL.
* get synonym name in case of multi use active
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
* iv_tabname = 'AUSP'
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
* set message
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
*
*
*
**** set additional target fields
GET TIME STAMP FIELD lv_timestamp.
CONCATENATE _mt_id ':R:R' INTO con_name.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET deleted = 'X'
delete_time = lv_timestamp
WHERE mandt = <wa_s_ausp>-mandt
AND objek = <wa_s_ausp>-objek
AND atinn = <wa_s_ausp>-atinn
AND atzhl = <wa_s_ausp>-atzhl
AND mafid = <wa_s_ausp>-mafid
AND klart = <wa_s_ausp>-klart
AND adzhl = <wa_s_ausp>-adzhl.
IF sy-subrc <> 0.
DATA(lc_subrc) = sy-subrc.
DATA lc_ausp TYPE c LENGTH 100.
CONCATENATE <wa_s_ausp>-mandt <wa_s_ausp>-objek <wa_s_ausp>-atinn <wa_s_ausp>-atzhl <wa_s_ausp>-mafid <wa_s_ausp>-klart <wa_s_ausp>-adzhl
INTO lc_ausp SEPARATED BY ','.
* set message
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Error Details:' lv_syn_name _cobj_alias lc_subrc 'IL '.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Table Details:' lc_ausp space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
**** do not replicate delete
skip_record.
ELSEIF sy-subrc = 0 AND <lv_operation> = 'I'.
GET TIME STAMP FIELD <wa_r_ausp>-insert_time.
ELSEIF sy-subrc = 0 AND <lv_operation> = 'U'.
GET TIME STAMP FIELD <wa_r_ausp>-update_time.
ELSE.
*Initial load branch
GET TIME STAMP FIELD <wa_r_ausp>-insert_time.
ENDIF.