SAP SLT into HANA not updating date field - abap

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.

Related

String to CRC32 as 4 bytes and LZMA1 conversion in ABAP

I need to for QR code payBySquare in Slovak republic convert Array to string and make CRC32 HASH. Afther that I need comprime HASH by LZMA1 . I hope my code is ok to CRC32 But I cannot find how to make comprimation by LZMA1.
method GENERATE_QR_STRING_FOR_SR.
DATA: lw_string TYPE STRING,
lw_wrbtr_s TYPE STRING,
lo_crc TYPE REF TO IF_SCV_CRC_SERVICES,
lo_crc_hash TYPE REF TO IF_SCV_CRC32.
LW_WRBTR_S = me->WRBTR.
CONCATENATE 'true'
LW_WRBTR_S "
me->WAERS "Currency
'20170101' "'Date'
me->VAR_SYMB "Variabile Symbol
me->CON_SYMB "Constant Symbol
me->SPE_SYMB "Specific Symbol
''
me->INF_FOR_BE "Information for benef..
'1'
me->IBAN "Iban
me->SWIFT "SWIFT
'0'
'0'
INTO lw_string SEPARATED BY ' '.
CONCATENATE '' '1' lw_string INTO lw_string SEPARATED BY ' '.
DATA:
ld_CONTENT TYPE XSTRING ,
ld_CRC32 TYPE I.
" ld_CONTENT = "<Populate with value>
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = LW_STRING
* MIMETYPE = ' '
* ENCODING =
IMPORTING
BUFFER = LD_CONTENT
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL METHOD CL_UJF_ZIP=>CRC32( EXPORTING CONTENT = ld_CONTENT RECEIVING CRC32 = ld_CRC32 ).
"ld_CRC32 = CL_RSBPCF_ZIP=>CRC32( EXPORTING CONTENT = ld_CONTENT ).

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

Modify an itab during looping another itab

I want to do the following
Loop at itab into wa_itab.
wa_itab2-field1 = wa_itab-field1.
wa_itab2-field2 = wa_itab-field2.
wa_itab2-field3 = wa_itab-field3.
wa_itab2-field4 = wa_itab-field4.
*how to insert in itab2 if fields 1,2 & 3 do not exist or update itab2 if fields 1,2 & 3 exist?
EndLoop.
Let me explain more.
I have itab with fields bukrs, kunnr, date, action.
The itab2 with fields bukrs, kunnr, name1 (from kna1),date01 (jan), action01, date02 (Feb), action02 ... date12 (Dec), action12.
During loop of itab I want if the itab2 has a record with bukrs and kunnr then it will update date and action according to the month of itab-date, if it do not exist (bukrs, kunnr) then insert a record to itab2.
I hope that this explains what I want.
Thanks in advance
Elias
PS. Here is the program
*&---------------------------------------------------------------------*
*& Report Z_COLLECTORS_ACTIONS
*&
*&---------------------------------------------------------------------*
*& Description
*&
*&---------------------------------------------------------------------*
*& Change log:
*& Date Author Action
*&
*&---------------------------------------------------------------------*
REPORT z_collectors_actions.
TABLES: zcollectoraction, kna1, t001.
TYPE-POOLS : slis.
TYPES: BEGIN OF ty_totalcollectoractions,
bukrs TYPE zcollectoraction-bukrs,
kunnr TYPE zcollectoraction-kunnr,
name1 TYPE kna1-name1,
date01 TYPE zcollectoraction-dat,
date02 TYPE zcollectoraction-dat,
date03 TYPE zcollectoraction-dat,
date04 TYPE zcollectoraction-dat,
date05 TYPE zcollectoraction-dat,
date06 TYPE zcollectoraction-dat,
date07 TYPE zcollectoraction-dat,
date08 TYPE zcollectoraction-dat,
date09 TYPE zcollectoraction-dat,
date10 TYPE zcollectoraction-dat,
date11 TYPE zcollectoraction-dat,
date12 TYPE zcollectoraction-dat,
action01 TYPE zcollectoraction-action,
action02 TYPE zcollectoraction-action,
action03 TYPE zcollectoraction-action,
action04 TYPE zcollectoraction-action,
action05 TYPE zcollectoraction-action,
action06 TYPE zcollectoraction-action,
action07 TYPE zcollectoraction-action,
action08 TYPE zcollectoraction-action,
action09 TYPE zcollectoraction-action,
action10 TYPE zcollectoraction-action,
action11 TYPE zcollectoraction-action,
action12 TYPE zcollectoraction-action,
END OF ty_totalcollectoractions.
DATA: wa_collectoraction LIKE zcollectoraction,
it_collectoraction LIKE TABLE OF zcollectoraction,
wa_totalcollectoractions TYPE ty_totalcollectoractions,
it_totalcollectoractions TYPE TABLE OF ty_totalcollectoractions WITH KEY kunnr.
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
field_catalog TYPE lvc_t_fcat,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid,
g_save TYPE c VALUE 'X',
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_exit TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
PARAMETERS: variant LIKE disvariant-variant.
PARAMETERS p_bukrs TYPE bukrs OBLIGATORY.
SELECT-OPTIONS: so_kunnr FOR kna1-kunnr OBLIGATORY,
so_date FOR sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK bl1.
INITIALIZATION.
gx_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
variant = gx_variant-variant.
ENDIF.
START-OF-SELECTION.
SELECT bukrs kunnr dat MAX( time ) AS time
FROM zcollectoraction INTO CORRESPONDING FIELDS OF TABLE it_collectoraction
WHERE bukrs = p_bukrs AND
kunnr IN so_kunnr AND
dat IN so_date
GROUP BY bukrs kunnr dat.
LOOP AT it_collectoraction INTO wa_collectoraction.
SELECT SINGLE * FROM zcollectoraction INTO CORRESPONDING FIELDS OF wa_collectoraction
WHERE bukrs = wa_collectoraction-bukrs AND
kunnr = wa_collectoraction-kunnr AND
dat = wa_collectoraction-dat AND
time = wa_collectoraction-time.
MODIFY it_collectoraction FROM wa_collectoraction.
wa_totalcollectoractions-bukrs = wa_collectoraction-bukrs.
wa_totalcollectoractions-kunnr = wa_collectoraction-kunnr.
SELECT SINGLE name1 FROM kna1 INTO wa_totalcollectoractions-name1
WHERE kunnr = wa_collectoraction-kunnr.
DATA lv_month TYPE n LENGTH 2.
lv_month = wa_collectoraction-dat+4(2).
CASE lv_month.
WHEN '01'.
wa_totalcollectoractions-date01 = wa_collectoraction-dat.
wa_totalcollectoractions-action01 = wa_collectoraction-action.
WHEN '02'.
wa_totalcollectoractions-date02 = wa_collectoraction-dat.
wa_totalcollectoractions-action02 = wa_collectoraction-action.
WHEN '03'.
wa_totalcollectoractions-date03 = wa_collectoraction-dat.
wa_totalcollectoractions-action03 = wa_collectoraction-action.
WHEN '04'.
wa_totalcollectoractions-date04 = wa_collectoraction-dat.
wa_totalcollectoractions-action04 = wa_collectoraction-action.
WHEN '05'.
wa_totalcollectoractions-date05 = wa_collectoraction-dat.
wa_totalcollectoractions-action05 = wa_collectoraction-action.
WHEN '06'.
wa_totalcollectoractions-date06 = wa_collectoraction-dat.
wa_totalcollectoractions-action06 = wa_collectoraction-action.
WHEN '07'.
wa_totalcollectoractions-date07 = wa_collectoraction-dat.
wa_totalcollectoractions-action07 = wa_collectoraction-action.
WHEN '08'.
wa_totalcollectoractions-date08 = wa_collectoraction-dat.
wa_totalcollectoractions-action08 = wa_collectoraction-action.
WHEN '09'.
wa_totalcollectoractions-date09 = wa_collectoraction-dat.
wa_totalcollectoractions-action09 = wa_collectoraction-action.
WHEN '10'.
wa_totalcollectoractions-date10 = wa_collectoraction-dat.
wa_totalcollectoractions-action10 = wa_collectoraction-action.
WHEN '11'.
wa_totalcollectoractions-date11 = wa_collectoraction-dat.
wa_totalcollectoractions-action11 = wa_collectoraction-action.
WHEN '12'.
wa_totalcollectoractions-date12 = wa_collectoraction-dat.
wa_totalcollectoractions-action12 = wa_collectoraction-action.
WHEN OTHERS.
ENDCASE.
READ TABLE it_totalcollectoractions INTO wa_totalcollectoractions
WITH TABLE KEY kunnr = wa_collectoraction-kunnr.
IF sy-subrc = 0.
MODIFY it_totalcollectoractions INDEX sy-tabix FROM wa_totalcollectoractions.
ELSE.
INSERT wa_totalcollectoractions INTO TABLE it_totalcollectoractions.
ENDIF.
ENDLOOP.
PERFORM build_fieldcatalog_agreggate.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = fieldcatalog[]
i_save = 'X'
is_variant = g_variant
TABLES
t_outtab = it_totalcollectoractions
EXCEPTIONS
program_error = 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.
ENDFORM. " DISPLAY_ALV_REPORT
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c,
lv_butxt TYPE butxt.
SELECT SINGLE butxt INTO lv_butxt FROM t001
WHERE bukrs = p_bukrs.
* Title
wa_header-typ = 'H'.
wa_header-info = 'Collectors'' Action Report'.
APPEND wa_header TO t_header.
CLEAR wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
APPEND wa_header TO t_header.
CLEAR: wa_header.
* Bukrs
wa_header-typ = 'S'.
wa_header-key = 'Company: '.
CONCATENATE p_bukrs lv_butxt INTO wa_header-info SEPARATED BY space.
APPEND wa_header TO t_header.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. "top-of-page
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG_AGREGGATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_fieldcatalog_agreggate .
fieldcatalog-fieldname = 'KUNNR'.
fieldcatalog-seltext_m = 'Customer ID'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Customer Name'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION01'.
fieldcatalog-seltext_m = 'January'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION02'.
fieldcatalog-seltext_m = 'February'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION03'.
fieldcatalog-seltext_m = 'March'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION04'.
fieldcatalog-seltext_m = 'April'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION05'.
fieldcatalog-seltext_m = 'May'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION06'.
fieldcatalog-seltext_m = 'June'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION07'.
fieldcatalog-seltext_m = 'July'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION08'.
fieldcatalog-seltext_m = 'August'.
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION09'.
fieldcatalog-seltext_m = 'September'.
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION10'.
fieldcatalog-seltext_m = 'Octomber'.
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION11'.
fieldcatalog-seltext_m = 'Noveber'.
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ACTION12'.
fieldcatalog-seltext_m = 'December'.
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG_AGREGGATE
If itab is not too big, then you can do like below.
clear: itab2[].
Loop at itab into wa_itab.
wa_itab2-field1 = wa_itab-field1.
wa_itab2-field2 = wa_itab-field2.
wa_itab2-field3 = wa_itab-field3.
wa_itab2-field4 = wa_itab-field4.
...
read table itab2 into data(ls_itab2) with key field1 = wa_itab2-field1
field2 = wa_itab2-field2
field3 = wa_itab2-field3
...
binary search.
if sy-subrc = 0 .
" modify the line
modify itab2 from wa_itab2 index sy-tabix.
else.
" append the line
append wa_itab2 to itab2.
sort itab2 ascending by field1 field2 field3 ... . "the key fields.
endif.
EndLoop.
FIELD-SYMBOLS: <fs_itab2> TYPE wa_itab2.
SORT itab2 BY bukrs kunnr.
LOOP AT itab INTO wa_itab.
***CHECK IF DATES EXIST***
READ TABLE itab2 ASSIGNING <fs_itab2> WITH KEY bukrs = wa_itab-bukrs
kunnr = wa_itab-kunnr
BINARY SEARCH.
if sy-subrc = 0 . "if the record are founded
<fs_itab2>-field1 = wa_itab-field1.
<fs_itab2>-field2 = wa_itab-field2.
<fs_itab2>-field3 = wa_itab-field3.
...
else.
APPEND INITIAL LINE TO itab2 ASSIGNING <fs_itab2>.
IF <fs_itab2> IS ASSIGNED.
<fs_itab2>-field1 = wa_itab-field1.
<fs_itab2>-field2 = wa_itab-field2.
<fs_itab2>-field3 = wa_itab-field3.
...
ENDIF.
ENDLOOP.
Thats is all with field symbols.
You do not need looping here, MOVE-CORRESPONDING do this for internal tables like a charm:
MOVE-CORRESPONDING src_tab TO target.
Here is the sample where MWST price conditions are selected into two itabs, then the currently valid ones are made invalid, then couple of additional invalid conditions with new key are added, and finally the second itab lt_upd_konh is updated, so that all MWST conditions in it gets invalidated with adding extra ones.
SELECT * FROM konh INTO TABLE #DATA(lt_konh) WHERE kschl = 'MWST'.
DATA(lt_upd_konh) = lt_konh.
LOOP AT lt_konh ASSIGNING FIELD-SYMBOL(<fs_konh>) WHERE datbi > sy-datum.
<fs_konh>-datbi = sy-datum - 1.
ENDLOOP.
<fs_konh>-knumh = 1000.
APPEND <fs_konh> TO lt_konh.
<fs_konh>-knumh = 1001.
APPEND <fs_konh> TO lt_konh.
<fs_konh>-knumh = 1002.
APPEND <fs_konh> TO lt_konh.
MOVE-CORRESPONDING lt_konh TO lt_upd_konh.

ABAP return to the initial selection screen after a write

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.

How to read the position value given the cost center

I want to read the position using this FM HRWPC_RPT_COSTCENTER_EVALPATH where the cost center is given.
There are 3 result tables. from which table I can read the position value ?
here how I call the FM:
DATA i_hrrootob TYPE TABLE OF hrrootob.
DATA w_hrrootob LIKE LINE OF i_hrrootob.
DATA i_object_tab TYPE TABLE OF objec.
DATA w_object_tab LIKE LINE OF i_object_tab.
data i_STRUC TYPE TABLE OF STRUC.
w_hrrootob-otype = 'K'.
w_hrrootob-objid = w_orgdata-costcenter_key-costcenter.
APPEND w_hrrootob TO i_hrrootob.
CALL FUNCTION 'HRWPC_RPT_COSTCENTER_EVALPATH'
EXPORTING
depth = 0
evpath = 'KOSTDIUP'
* PLVAR = 01
* BEGDA = SY-DATUM
* ENDDA = SY-DATUM
* LEVEL = 1
TABLES
root_objects = i_hrrootob
result_objec = i_object_tab
result_struc = i_STRUC
EXCEPTIONS
NO_OBJECTS_FOUND = 1
OTHERS = 2
.
I got it by myself.
The result table result_objec has the value in the field stext, where the obtype ='S'