I have this ABAP code:
CLEAR NEGATIIVNE.
DATA gv_negativenumericvalue_txt TYPE CHAR40.
SELECT SINGLE NETWR INTO NEGATIIVNE
FROM VBRK
WHERE VBELN = VBRK-VBELN.
IF DEBIT_CREDIT = 'CRED'.
NEGATIIVNE = NEGATIIVNE * -1.
ELSE.
NEGATIIVNE = NEGATIIVNE.
ENDIF.
WRITE NEGATIIVNE TO gv_negativenumericvalue_txt.
REPLACE ALL OCCURRENCES OF '.' in gv_negativenumericvalue_txt with ''.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = gv_negativenumericvalue_txt.
CALL FUNCTION 'MOVE_CHAR_TO_NUM '
EXPORTING
CHR = gv_negativenumericvalue_txt
IMPORTING
NUM = NEGATIIVNE
EXCEPTIONS
CONVT_NO_NUMBER = 1
CONVT_OVERFLOW = 2
OTHERS = 3.
write:/ gv_negativenumericvalue_txt.
What I need to do is write variable gv_negativenumericvalue_txt into variable NEGATIIVNE but I can't do it any way :/ I need it do show the value NEGATIIVNE in my ALV layout.
Right now the code works fine but as soon as I try to do something like this -
NEGATIIVNE = gv_negativenumericvalue_txt I get dump saying that system can't recognize the character as number.
It seems that the requirement you got is that the net value of billing documents should be shown in 1 format, not respecting the settings of the user which control the decimal notation.
The only way to do that, is to use a 21 char (you dont need 40) field instead of NEGATIIVNE in your ALV.
On a side note, because NEGATIIVNE = NEGATIIVNE. does not do anything I would write
IF DEBIT_CREDIT = 'CRED'.
NEGATIIVNE = NEGATIIVNE * -1.
ELSE.
NEGATIIVNE = NEGATIIVNE.
ENDIF.
as
IF DEBIT_CREDIT = 'CRED'.
NEGATIIVNE = NEGATIIVNE * -1.
ENDIF.
Related
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.
Say I have a table with customers, which is shown in an alv-grid like so:
**BEFORE THIS: Set up parameters, SQL Select, Table etc.
CREATE OBJECT gr_alv_grid
EXPORTING
i_parent = cl_gui_custom_container=>default_screen
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
ENDIF.
gr_alv_grid->set_table_for_first_display(
EXPORTING
i_structure_name = 'ZDebcdstest'
CHANGING
it_outtab = lt_debis
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
What I would like to have is the option to double-click on any given row and get a more detailed overview of the object contained therein, like for instance done in SE16. I have already set up an Event Handler to listen for a double click, which works, but I haven't figured out how to get all the relevant data in a row and display the chosen object in full detail.
Any help is greatly appreciated.
Here is the primitive sample how to make it work "like for instance done in SE16'
METHOD handle_double_click.
DATA: ls_sflight LIKE LINE OF gt_sflight,
ls_layout TYPE lvc_s_layo.
DATA: lt_fieldcatalog TYPE lvc_t_fcat,
ls_fieldcatalog TYPE lvc_s_fcat.
DATA: details_outtab TYPE lvc_t_detm,
ls_detail TYPE lvc_s_detm,
lt_detail_tab TYPE lvc_t_deta,
ls_detail_tab TYPE lvc_s_deta.
READ TABLE gt_sflight INDEX e_row-index INTO ls_sflight.
ls_fieldcatalog-fieldname = 'COLUMNTEXT'.
ls_fieldcatalog-ref_table = 'LVC_S_DETA'.
ls_fieldcatalog-key = 'X'.
ls_fieldcatalog-seltext = 'Field'.
ls_fieldcatalog-outputlen = 30.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'VALUE'.
ls_fieldcatalog-ref_table = 'LVC_S_DETA'.
ls_fieldcatalog-seltext = 'Field value'.
ls_fieldcatalog-outputlen = 20.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_layout-no_toolbar = 'X'.
LOOP AT gt_fieldcat ASSIGNING FIELD-SYMBOL(<field>).
ls_detail_tab-columntext = <field>-scrtext_l.
ASSIGN COMPONENT sy-tabix OF STRUCTURE ls_sflight TO FIELD-SYMBOL(<col>).
ls_detail_tab-value = <col>.
APPEND ls_detail_tab TO lt_detail_tab.
ENDLOOP.
ls_detail-detailtab = lt_detail_tab.
APPEND ls_detail TO details_outtab.
CALL FUNCTION 'LVC_ITEM_DETAIL'
EXPORTING
i_title = 'Row details'
it_fieldcatalog = lt_fieldcatalog
is_layout = ls_layout
TABLES
t_outtab = details_outtab.
ENDMETHOD. "handle_double_click
in the above snippet
gt_sflight - main table you wanna capture row details from
gt_fieldcat - field catalog of this table which must be populated before firing the event
if you don't know how apply this method to your ALV, search for some tutorial about event implementation.
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
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.
I have the next problem to show a popup AVL. My error is the next:
The statement
"MOVE src TO dst"
requires that the operands "dst" and "src" are convertible.
Since this statement is in a Unicode program, the special conversion
rules for Unicode programs apply.
In this case, these rules were violated.
My code is the next:
TYPES:
BEGIN OF ty_posic,
ebelp TYPE EKPO-EBELP,
posid TYPE PRPS-POSID,
texto TYPE PRPS-POST1,
impor TYPE NETPR,
waers TYPE EKKO-WAERS,
END OF ty_posic.
* Tablas internas.
DATA:
t_posic TYPE STANDARD TABLE OF ty_posic,
t_cols TYPE STANDARD TABLE OF help_value,
t_tabix TYPE sy-tabix,
t_just TYPE CATSXT_LONGTEXT_ITAB.
* Workareas.
DATA:
wa_cols LIKE LINE OF t_cols,
wa_posic LIKE LINE OF t_posic.
..........
CLEAR t_tabix.
APPEND wa_cols TO t_cols.
wa_cols-tabname = 'EKPO'.
wa_cols-fieldname = 'EBELP'.
wa_cols-selectflag = 'X'.
APPEND wa_cols TO t_cols.
wa_cols-tabname = 'PRPS'.
wa_cols-fieldname = 'POSID'.
APPEND wa_cols TO t_cols.
wa_cols-tabname = 'PRPS'.
wa_cols-fieldname = 'POST1'.
APPEND wa_cols TO t_cols.
wa_cols-tabname = 'EKPO'.
wa_cols-fieldname = 'NETPR'.
APPEND wa_cols TO t_cols.
wa_cols-tabname = 'EKKO'.
wa_cols-fieldname = 'WAERS'.
APPEND wa_cols TO t_cols.
CALL FUNCTION 'MD_POPUP_SHOW_INTERNAL_TABLE'
EXPORTING
title = 'My text'
IMPORTING
index = t_tabix
TABLES
values = t_posic
columns = t_cols
EXCEPTIONS
leave = 1
others = 2.
...........
Greethings!