How to update custom fields in PLM project definition? - abap

I am required to create a custom report that bulk uploads the PROJ table, that has around 8 custom fields that have been created by a Fiori app, the data to be updated would be provided as a CSV file and would have the project id for which the data has to be created.
The fields as created are visible in transaction codes CJ20N and CJ02.
The issue is that despite having the data added, the BAPI is not giving any error and no data is getting updated.
Please help me resolve this issue or suggest an alternative solution to achieve the required.
Following is my code so far, based on BAPI_PS_INITIALIZATION, BAPI_BUS2001_CHANGE, BAPI_PS_PRECOMMIT and BAPI_TRANSACTION_COMMIT:
REPORT z_bulk_proj_upload.
TYPES: BEGIN OF ty_data,
project TYPE ps_pspnr,
vip_id(18) TYPE c, "VIP ID
category(30) TYPE c, "LA Category
worktype(30) TYPE c, "LA WorkType
projtype(30) TYPE c, "LA ProjectType
region(30) TYPE c, "Region
alpharisk(20) TYPE c, "AlphaRiskControl
vipcontrol(3) TYPE c, "VIP Control
viprevised(3) TYPE c, "VIP Revised Control
majorproject(1) TYPE c, "Major Project Threshold
dateofinteg(10) TYPE c, "Date of integration
filenumber(16) TYPE c, "File Number Regie
decisiondate(10) TYPE c, "Decision Date Regie
approval(10) TYPE c, "Approval
END OF ty_data,
BEGIN OF lty_rawdata,
rawdata(40000) TYPE c,
END OF lty_rawdata.
DATA: it_data TYPE STANDARD TABLE OF ty_data,
lwa_data TYPE ty_data,
lv_file TYPE string,
it_rawdata TYPE STANDARD TABLE OF lty_rawdata,
lwa_rawdata TYPE lty_rawdata,
lr_csv TYPE REF TO cl_rsda_csv_converter,
lt_fichier TYPE filetable,
l_rc TYPE i,
lv_length TYPE i,
lv_size TYPE i,
ls_proj TYPE proj,
wa_custstr TYPE bapi_te_project_definition,
ls_project_definition TYPE bapi_bus2001_chg,
ls_project_definition_upd TYPE bapi_bus2001_upd,
lt_return TYPE STANDARD TABLE OF bapiret2,
lt_return1 TYPE bapiret2,
lt_extensionin TYPE STANDARD TABLE OF bapiparex INITIAL SIZE 0 WITH HEADER LINE.
INITIALIZATION.
CLEAR: lv_size, it_data.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE TEXT-b05.
PARAMETERS: p_file TYPE rlgrap-filename LOWER CASE,
p_upld RADIOBUTTON GROUP grz DEFAULT 'X',
p_dwnld RADIOBUTTON GROUP grz.
SELECTION-SCREEN END OF BLOCK b4.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE TEXT-b05.
PARAMETERS: p_file TYPE rlgrap-filename LOWER CASE,
p_upld RADIOBUTTON GROUP grz DEFAULT 'X',
p_dwnld RADIOBUTTON GROUP grz.
SELECTION-SCREEN END OF BLOCK b4.
START-OF-SELECTION.
IF p_upld IS NOT INITIAL.
lv_file = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_file
CHANGING
data_tab = it_rawdata[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE 'Error in Upload' TYPE 'E'.
ELSE.
DESCRIBE TABLE it_data LINES DATA(lv_line).
ENDIF.
CALL METHOD cl_rsda_csv_converter=>create
RECEIVING
r_r_conv = lr_csv.
LOOP AT it_rawdata INTO lwa_rawdata.
TRY.
"Populate raw data into separate fields in structure
CALL METHOD lr_csv->csv_to_structure
EXPORTING
i_data = lwa_rawdata
IMPORTING
e_s_data = lwa_data.
CATCH cx_root ##CATCH_ALL.
"Error during data conversion
MESSAGE TEXT-005 TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDTRY.
APPEND lwa_data TO it_data.
ENDLOOP.
ENDIF.
IF it_data IS NOT INITIAL.
LOOP AT it_data INTO lwa_data.
SELECT SINGLE * INTO ls_proj FROM proj WHERE pspid = lwa_data-project.
lt_extensionin-structure = 'BAPI_TE_PROJECT_DEFINITION'.
lt_extensionin-valuepart1+0(24) = ls_proj-pspid.
APPEND lt_extensionin.
CALL FUNCTION 'BAPI_PS_INITIALIZATION'.
ls_project_definition-project_definition = ls_proj-pspid.
ls_project_definition_upd-zz1_vipid_psd = lwa_data-vip_id.
ls_project_definition_upd-zz1_lacategory_psd = lwa_data-category.
ls_project_definition_upd-zz1_laworktype_psd = lwa_data-worktype.
ls_project_definition_upd-zz1_laprojecttype_psd = lwa_data-projtype.
ls_project_definition_upd-zz1_region_psd = lwa_data-region.
ls_project_definition_upd-zz1_alphariskgrade1_psd = lwa_data-alpharisk.
ls_project_definition_upd-zz1_vipcontrolnonc_psd = lwa_data-vipcontrol.
ls_project_definition_upd-zz1_viprevisedcontroln_psd = lwa_data-viprevised.
ls_project_definition_upd-zz1_majorprojectsthres_psd = lwa_data-project.
ls_project_definition_upd-zz1_dateofintegrationi_psd = lwa_data-dateofinteg.
ls_project_definition_upd-zz1_filenumberrgie_psd = lwa_data-filenumber.
ls_project_definition_upd-zz1_decisiondatergie_psd = lwa_data-decisiondate.
ls_project_definition_upd-zz1_approval_psd = lwa_data-approval.
CALL FUNCTION 'BAPI_BUS2001_CHANGE'
EXPORTING
i_project_definition = ls_project_definition
i_project_definition_upd = ls_project_definition_upd
TABLES
et_return = lt_return.
* extensionin = lt_extensionin.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
et_return = lt_return.
REFRESH lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = lt_return1.
ENDLOOP.
ENDIF.

i_project_definition is for the update flag not the actual value.
ls_project_definition-fieldxyz = 'SOME VALUE'.
ls_project_definition_upd-fieldxyz = 'X'. " should have the value 'X' !!!
the code you supplied suggests the interface was not called properly.
Furthermore for Z fields normally they are passed in via EXTENSIONIN not via
BAPI_BUS2001_CHG and BAPI_BUS2001_UPD.
FUNCTION BAPI_BUS2001_CHANGE
IMPORTING
VALUE(I_PROJECT_DEFINITION) LIKE BAPI_BUS2001_CHG
VALUE(I_PROJECT_DEFINITION_UPD) LIKE BAPI_BUS2001_UPD
TABLES
ET_RETURN LIKE BAPIRET2 OPTIONAL
EXTENSIONIN LIKE BAPIPAREX OPTIONAL "<<<<<<<<<<<<< HERE
EXTENSIONOUT LIKE BAPIPAREX OPTIONAL.

Related

BAPI_GOODSMVT_CREATE in parallel mode causes "plant data of the material XXX is locked" error

Currently, We're developing mass GI posting by parallelism, to reduce work time dramatically, because we have to post GI item about 300k+ at one day.
Problem
I know there is a restraint about BAPI_GOODSMVT_CREATE - You can't post same material simutaneously because of table lock, so I grouped materials like this :
It seems reasonable, so I make parallel job for each material number, which total 7 in example.
When I try process this process, SAP refused to process with error :
M3 897 : The plant data of the material XXX is locked by the user XXX
Question
The error is about plant data, not stock data - so it's really confusing about why this error happening.
Is there a more restraint about BAPI_GOODSMVT_CREATE?
Note 369518 won't help about this situation.
Any help would be appreciated!
Program Code
LOOP AT gt_matnr_collect INTO wa_matnr_collect.
WAIT UNTIL g_progs <= pa_wpnum.
g_progs = g_progs + 1.
CALL FUNCTION 'Z_PP_STAMP_PARA_DISTRIBUTE'
STARTING NEW TASK g_task DESTINATION IN GROUP DEFAULT
PERFORMING return_stamp_para ON END OF TASK
EXPORTING
p_matnr = wa_matnr_collect-gi_code
p_spmon = p_spmon
TABLES
p_list = gt_main_para_list
p_item = gt_main.
g_task = g_task + 1.
g_sprog = g_sprog + 1.
ENDLOOP.
gt_matnr_collect looks like this :
gt_main_para_list looks like this :
gt_main looks like this :
FM 'Z_PP_STAMP_PARA_DISTRIBUTE'
FUNCTION z_pp_stamp_para_distribute.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(P_MATNR) TYPE MATNR_D
*" VALUE(P_SPMON) TYPE SPMON
*" EXPORTING
*" VALUE(E_MATNR) TYPE MATNR_D
*" TABLES
*" P_LIST STRUCTURE ZSPP6030_PA_LIST
*" P_ITEM STRUCTURE ZSPP6030_PA_ITEM
*" R_RESULT STRUCTURE BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
DATA : gs_head LIKE bapi2017_gm_head_01,
gs_gmcd LIKE bapi2017_gm_code,
gs_doc LIKE bapi2017_gm_head_ret,
gt_item LIKE TABLE OF bapi2017_gm_item_create
WITH HEADER LINE,
gt_return LIKE TABLE OF bapiret2 WITH HEADER LINE,
gs_return LIKE bapiret2,
group_id(22) TYPE c,
l_begda LIKE p0001-begda,
g_last_date TYPE d,
lv_matnr TYPE ztpp5360-gi_code,
lv_batch TYPE ztpp5360-gi_batch,
lv_aufnr TYPE ztpp5360-arbpl,
lv_cnt(3) TYPE c.
CONCATENATE p_spmon '01' INTO l_begda.
e_matnr = p_matnr.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = l_begda
IMPORTING
last_day_of_month = g_last_date
EXCEPTIONS
day_in_no_date = 1
OTHERS = 2.
CONCATENATE p_matnr '*' INTO group_id.
LOOP AT p_list WHERE group_id CP group_id.
CLEAR : lv_matnr, lv_batch, lv_aufnr, lv_cnt.
SPLIT p_list-group_id AT '-' INTO lv_matnr lv_batch lv_aufnr lv_cnt.
CASE lv_batch.
WHEN 'EMPTY'.
lv_batch = ''.
ENDCASE.
p_list-status = 'WIP'.
MODIFY p_list.
LOOP AT p_item WHERE group_id = p_list-group_id.
MOVE : p_item-gi_m_q TO gt_item-entry_qnt,
* 'KG' TO gt_item-entry_uom,
'X' TO gt_item-withdrawn,
'3100' TO gt_item-stge_loc.
MOVE : '261' TO gt_item-move_type,
p_item-gi_code TO gt_item-material,
p_item-werks TO gt_item-plant,
p_item-aufnr TO gt_item-orderid,
lv_batch TO gt_item-batch.
APPEND : gt_item. CLEAR : gt_item.
ENDLOOP.
MOVE : g_last_date TO gs_head-doc_date,
g_last_date TO gs_head-pstng_date,
'03' TO gs_gmcd-gm_code.
REFRESH : gt_return.
CLEAR : gt_return, gs_doc.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gs_head
goodsmvt_code = gs_gmcd
IMPORTING
goodsmvt_headret = gs_doc
TABLES
goodsmvt_item = gt_item
return = gt_return.
READ TABLE gt_return WITH KEY type = 'E'.
IF sy-subrc = 0 OR gs_doc IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT p_item WHERE group_id = p_list-group_id.
p_item-ecode = 'E'.
p_item-msgtx = gt_return-message.
p_item-aedat = sy-datum.
p_item-aezet = sy-uzeit.
p_item-aenam = sy-uname.
MODIFY p_item.
ENDLOOP.
p_list-status = 'ERR'.
p_list-msgty = 'E'.
CONCATENATE gt_return-message '/' gt_return-id '/' gt_return-number INTO p_list-msgtx.
MODIFY p_list.
ELSE.
CLEAR : gs_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = gs_return.
IF gs_return-type = 'E'.
p_list-status = 'ERR'.
p_list-msgty = 'E'.
p_list-msgtx = gs_return-message.
ELSE.
LOOP AT p_item WHERE group_id = p_list-group_id.
p_item-gi_m_mblnr = gs_doc-mat_doc.
p_item-gi_m_mjahr = gs_doc-doc_year.
p_item-ecode = 'S'.
p_item-msgtx = ''.
p_item-aedat = sy-datum.
p_item-aezet = sy-uzeit.
p_item-aenam = sy-uname.
MODIFY p_item.
ENDLOOP.
p_list-status = 'FIN'.
p_list-msgty = 'S'.
p_list-msgtx = ''.
MODIFY p_list.
ENDIF.
ENDIF.
REFRESH : gt_item.
CLEAR : gs_head, gs_gmcd.
WAIT UP TO 2 SECONDS.
ENDLOOP.
ENDFUNCTION.

How can I use dynamic SALV with 3 different raditobutton in OO ABAP

I have to do Batch program for 3 different info types (0014,0015,2010).
First step, I have a parameter that is reading the .xls file in a selection screen and 3 different radio buttons for each info type. I want to display a different ALV as when I execute the program with selected radio button. For example, I want to see 0014 if I selected 0014's radio button. The same situation for others.
I can do what I want with one way. That's way is using Perform which have parameters tables and using.
But I cannot do it with OO ABAP. It means using SALV and CLASS/Method style.
Anyone can guide me?
*------------DEFINITION--------
class lcl_report definition.
public section.
types: begin of ty_list_14,
pernr(8) type c,
begda(10) type c,
endda(10) type c,
lgart(5) type c,
betrg(9) type c,
anzhl type i,
message(200) type c,
durum(5) type c,
end of ty_list_14.
data: gt_list_14 type standard table of ty_list_14,
gs_list_14 like line of gt_list_14.
methods:
check_filename,
file_operations,
display_alv.
private section.
data: mo_alv type ref to cl_salv_table.
data: gt_rows type salv_t_row,
gs_rows type i.
data: it_raw type truxs_t_text_data.
data: v_strln type i,
offset type i,
extension type string.
data: i_0014 type table of p0014 initial size 1,
w_0014 type p0014,
l_bapireturn type bapireturn1.
data: filename type string.
methods:
create_alv,
selection_rows,
alv_properties,
upload_file,
create_record_i0014.
methods :
on_user_command for event added_function of cl_salv_events
importing e_salv_function.
endclass.
*------------IMPLEMENTATION--------
class lcl_report implementation.
method display_alv.
me->create_alv( ).
me->selection_rows( ).
me->alv_properties( ).
endmethod.
method file_operations.
me->upload_file( ).
endmethod.
method create_alv.
data: lo_events type ref to cl_salv_events_table.
try.
cl_salv_table=>factory(
importing
r_salv_table = mo_alv
changing
t_table = gt_list_14[]
).
catch cx_salv_msg.
endtry.
lo_events = mo_alv->get_event( ).
set handler go_report->on_user_command for lo_events.
mo_alv->display( ).
endmethod.
method selection_rows .
data: lo_selection type ref to cl_salv_selections.
try.
"Soldan seçim kutularını ekrana getirir.
lo_selection = mo_alv->get_selections( ).
lo_selection->set_selection_mode( if_salv_c_selection_mode=>row_column ).
catch cx_salv_not_found.
endtry.
endmethod.
method check_filename.
v_strln = strlen( p_file ).
if v_strln le 4.
message text-003 type 'E'.
else.
offset = v_strln - 1.
do v_strln times.
if p_file+offset(1) eq '.'.
extension = p_file+offset.
shift extension left deleting leading '.'.
exit.
endif.
subtract 1 from offset.
enddo.
if extension ne 'xls' and
extension ne 'XLS' and
extension ne 'xlsx' and
extension ne 'XLSX' and
extension ne 'txt' and
extension ne 'TXT'.
message text-003 type 'E'.
endif.
endif.
endmethod.
method create_record_i0014.
data: lv_begda type begda,
lv_endda type endda.
loop at gt_rows into gs_rows.
read table gt_list_14 into gs_list_14 index gs_rows.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = gs_list_14-pernr
importing
output = gs_list_14-pernr.
call function 'CONVERSION_EXIT_QNTY1_INPUT'
exporting
input = gs_list_14-betrg
importing
output = gs_list_14-betrg.
clear: lv_begda, lv_endda.
concatenate gs_list_14-begda+6(4)
gs_list_14-begda+3(2)
gs_list_14-begda(2)
into lv_begda.
concatenate gs_list_14-endda+6(4)
gs_list_14-endda+3(2)
gs_list_14-endda(2)
into lv_endda.
move-corresponding gs_list_14 to w_0014.
w_0014-infty = '0014'.
w_0014-begda = lv_begda.
w_0014-endda = lv_endda.
w_0014-lgart = gs_list_14-lgart.
w_0014-betrg = gs_list_14-betrg.
w_0014-anzhl = gs_list_14-anzhl.
append w_0014 to i_0014.
call function 'BAPI_EMPLOYEE_ENQUEUE'
exporting
number = w_0014-pernr
importing
return = l_bapireturn.
call function 'HR_INFOTYPE_OPERATION'
exporting
infty = '0014'
number = w_0014-pernr
record = w_0014
operation = 'INS'
importing
return = l_bapireturn.
gs_list_14-message = l_bapireturn-message.
if l_bapireturn-type eq 'E'.
gs_list_14-durum = '#5C#'.
elseif l_bapireturn-type eq 'W'.
gs_list_14-durum = '#5D#'.
elseif l_bapireturn-type eq 'S' or
l_bapireturn-type is initial.
gs_list_14-durum = '#5B#'.
gs_list_14-message = text-033.
endif.
call function 'BAPI_EMPLOYEE_DEQUEUE'
exporting
number = w_0014-pernr
importing
return = l_bapireturn.
modify gt_list_14 from gs_list_14 index gs_rows.
clear: gs_list_14, w_0014.
refresh i_0014.
endloop.
endmethod.
method on_user_command.
data: lo_selection type ref to cl_salv_selections.
lo_selection = mo_alv->get_selections( ).
gt_rows = lo_selection->get_selected_rows( ).
case e_salv_function.
when '&AKTAR'.
me->create_record_i0014( ).
endcase.
mo_alv->refresh( ).
endmethod.
endclass.
You need create a field-symbol like Excel table structure and set this field-symbol in the SALV.
See this post to know how to create the field-symbol.
Create a structure from a dynamically assigned <itab>
Best regards.
Sebastian

Read material text for multiple languages at the same time with READ_TEXT FM

I have managed to make the READ_TEXT FM work only for one cID at a time on multiple calls of function read_text(for example I found out how to access it for cID = 'GRUN' cObject = 'MATERIAL'. Can anyone advise how to connect read_text function so that inspection text(cID = 'GRUN' cObject = 'MATERIAL') will be dispalyed in my alv grid on the same line with material details?
FORM READTEXT.
data: it_MVKE type standard table of MVKE initial size 0.
data: lMVKE like MVKE, lMAKT like MAKT, lT002 like T002 ,
lTDNAME like THEAD-TDNAME,"text header
it_TLINE type standard table of TLINE,
wa_TLINE type TLINE.
data: cObject(10) type c, cID(4) type c.
select MATNR from MARA into corresponding fields of table it_MVKE
where MATNR in Material order by MATNR.
cID = 'GRUN'. cObject = 'MATERIAL'. "Text date principale "
loop at it_MVKE into lMVKE.
lTDNAME = lMVKE-MATNR.
select spras from T002 into lT002.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = cID
LANGUAGE = lT002-SPRAS
NAME = lTDNAME
OBJECT = cObject
TABLES
LINES = it_TLINE
EXCEPTIONS
ID = 1
OTHERS = 8.
IF SY-SUBRC EQ 0.
select single * from MAKT into lMAKT where MATNR eq lMVKE-MATNR
and SPRAS eq lT002-SPRAS.
LOOP AT it_TLINE INTO wa_TLINE.
wa_join-TEXTPRI = wa_TLINE-TDLINE.
append wa_join to lt_join.
clear wa_join.
ENDLOOP.
ENDIF.
ENDSELECT.
ENDLOOP.
ENDFORM.
You cannot do like this. Function modules in SAP accept only single parameter at one time, unless this parameter is specified as a table type or in TABLES section.
However, here is workaround from my previous answer you can use to get rid of READ_TEXT at all.
As forgetaboutme said, put you cIDs into itab together with TDNAMEs:
wa_cids-cid = 'GRUN'.
wa_cids-cobject = 'MATERIAL'.
if cID = '0001'.
concatenate lMVKE-MATNR lMVKE-VKORG lMVKE-VTWEG into wa_cids-lTDNAME.
else.
lTDNAME = lMVKE-MATNR.
endif.
append wa_cids to it_cids.
Select texts from db table considering your itab.
SELECT l~tdname l~clustr l~clustd
INTO CORRESPONDING FIELDS OF TABLE t_stxl
FROM stxl AS l
JOIN stxh AS h
ON h~tdobject = l~tdobject
AND h~tdname = l~tdname
AND h~tdid = l~tdid
FOR ALL ENTRIES it_cids
WHERE l~relid = 'TX' "standard text
AND h~tdobject = it_cids-cobject
AND h~tdname = it_cids-lTDNAME
AND h~tdid = it_cids-cid
AND l~tdspras = sy-langu.
Convert them from raw form into readable form
CLEAR: t_stxl_raw[], t_tline[].
APPEND VALUE ty_stxl_raw( clustr = <stxl>-clustr clustd = <stxl>-clustd ) TO t_stxl_raw.
IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.
Read them
LOOP AT t_tline ASSIGNING <tline>.
wa_Report-TEXT = <tline>-TDLINE.
append wa_Report to it_Report.
ENDLOOP.
You can create an internal table of cIDs & cObjects like this:
types: begin of cids,
cid(4) type c,
cobject(10) type c,
end of cids.
data: wa_cids type cids.
data: it_cids type standard table of cids.
Then you can simply append all the different types of cIDs/cObjects you have to your internal table:
wa_cids-cid = 'GRUN'.
wa_cids-cobject = 'MATERIAL'.
append wa_cids to it_cids.
Then loop over your internal table calling function 'READ_TEXT'
loop at it_cids into wa_cids.
call function 'READ_TEXT'
exporting
client = sy-mandt
id = wa_cids-cid
language = lt002-spras "p_SPRAS
name = ltdname
object = wa_cids-cobject
tables
lines = it_tline
exceptions
id = 1
others = 8.
* Do what you need to do with it_tline here.
endloop.
* Rest of code here

Allow free text in ALV Grid cell with dropdown

I have set a dropdown list for an ALV Grid cell. The dropdow works fine, but it allows to enter values from the dropdown value list only. Is it possible to allow free text entry in the cell?
My ABAP code is:
Creating a value list:
DATA: lt_dropdown TYPE lvc_t_dral,
ls_dropdown TYPE lvc_s_dral.
data: ls_taba TYPE dd07v,
lt_taba TYPE STANDARD TABLE OF dd07v,
lt_tabb TYPE STANDARD TABLE OF dd07v.
CALL FUNCTION 'DD_DOMA_GET'
EXPORTING
DOMAIN_NAME = 'ZBC_TRADE_NETWORK'
LANGU = SY-LANGU
WITHTEXT = 'X'
TABLES
DD07V_TAB_A = lt_taba
DD07V_TAB_N = lt_tabb
EXCEPTIONS
ILLEGAL_VALUE = 1
OP_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
return.
ENDIF.
loop at lt_taba into ls_taba.
ls_dropdown-handle = '1'.
ls_dropdown-int_value = ls_taba-domvalue_l.
ls_dropdown-value = ls_taba-ddtext.
APPEND ls_dropdown TO lt_dropdown.
endloop.
*method to display the dropdown in ALV
CALL METHOD go_grid->set_drop_down_table
EXPORTING
IT_DROP_DOWN_ALIAS = lt_dropdown.
Fill the field catalogue:
data: ls_fcat type lvc_s_fcat,
lt_fcat type lvc_t_fcat.
field-symbols: <lfs_fcat> type ls_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = gc_struct_name
changing
ct_fieldcat = lt_fcat
exceptions
others = 1.
loop at lt_fcat assigning <lfs_fcat>.
case <lfs_fcat>-fieldname.
when 'NETWORK'.
<lfs_fcat>-drdn_hndl = '1'.
<lfs_fcat>-drdn_alias = 'X'.
<lfs_fcat>-edit = abap_on.
endcase.
endloop.
Set ALV grid for display
go_grid->set_table_for_first_display(
exporting
i_save = lf_save
i_default = lf_default
is_variant = ls_vari
is_layout = ls_layo
it_toolbar_excluding = lt_excl
changing
it_outtab = <lfs_t_data>
it_fieldcatalog = lt_fcat
exceptions
others = 1
).
No. A drop-down field implies a fixed value set. If you want to have both a value catalog and a text editing facility, use a value help (F4 help) to implement the catalog access.

How to display list of attachments from Generic Object Services

I have a report that should display an attachment list from an object.
For instance, in transaction FI02 (maintenance of banks), the GOS toolbar has the menu Attachment List:
I want to display this list. What is the best way to display it?
REPORT zay_gos_demo.
DATA ls_appl_object TYPE gos_s_obj.
DATA lo_gos_api TYPE REF TO cl_gos_api.
DATA lt_attachment_list TYPE gos_t_atta.
DATA lt_role_filter TYPE gos_t_rol.
DATA ls_attachment TYPE gos_s_atta.
DATA ls_attachm_cont TYPE gos_s_attcont.
DATA ls_atta_key TYPE gos_s_attkey.
ls_appl_object-typeid = 'KNA1'.
ls_appl_object-instid = '0000000001'.
ls_appl_object-catid = 'BO'. "BO - BOR Object
"CL - Persistent Class
START-OF-SELECTION.
* create instance of GOS API providing unique application object
TRY.
lo_gos_api = cl_gos_api=>create_instance( ls_appl_object ).
* get attachment list for this object (if needed restrict selection
* by adding certain roles to filter table; initial table means: get
* attachments in all roles)
APPEND cl_gos_api=>c_attachment TO lt_role_filter.
APPEND cl_gos_api=>c_annotation TO lt_role_filter.
APPEND cl_gos_api=>c_website TO lt_role_filter.
lt_attachment_list = lo_gos_api->get_atta_list( lt_role_filter ).
CATCH cx_gos_api.
* error handling
ENDTRY.
I found other example and I want to test it:
REPORT zay_attachment_list_display.
DATA: go_attachments TYPE REF TO cl_gos_attachments,
g_att_container TYPE REF TO cl_gui_custom_container,
ls_object TYPE borident,
lo_bitem TYPE REF TO cl_sobl_bor_item.
ls_object-objtype = 'KNA1'.
ls_object-objkey = '0000000001'.
IF NOT go_attachments IS INITIAL.
CLEAR go_attachments.
ENDIF.
CREATE OBJECT g_att_container
EXPORTING
container_name = 'ATTS'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
* ADD your handling
ENDIF.
CREATE OBJECT lo_bitem
EXPORTING
is_bor = ls_object.
IF go_attachments IS INITIAL.
CREATE OBJECT go_attachments
EXPORTING
io_object = lo_bitem
ip_check_arl = 'X'
ip_check_bds = 'X'
io_container = g_att_container
* is_layout = ls_layout
* ip_mode = wf_mode
ip_notes = 'X'
ip_attachments = 'X'
ip_urls = 'X'.
ELSE.
go_attachments->set_container( g_att_container ).
ENDIF.
go_attachments->display( ).
I created a custom control in dynpro 0100 and I named it ATTS. I still can't get the attachment list of GOS. Did I miss something?
After weeks of searching and asking. it was really simple. just call the function GOS_ATTACHMENT_LIST_POPUP.
Example:
DATA: ls_object TYPE sibflporb,
save_request TYPE sgs_flag.
ls_object-instid = 'FR 1234567890'.
ls_object-typeid = 'BUS1011'.
ls_object-catid = 'BO'.
CALL FUNCTION 'GOS_ATTACHMENT_LIST_POPUP'
EXPORTING
is_object = ls_object
ip_mode = 'E' " Edit mode
IMPORTING
ep_save_request = save_request.
IF save_request = 'X'.
COMMIT WORK.
ENDIF.