2020 Jan 10 1:08 PM
Dear Experts,
I'm trying to learn how to automaticaly call a screen and skip first screen. I added hotspot line under charge number and material number but i couldn't write a code for calling MSC3N and MM03. Could you please help, here is my code:
PS: i tried adding
EXPORTING
i_callback_user_command = 'USER_COMMAND'
.
.
.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
call transaction 'MM03'.
endform.
but nothing happens
REPORT zalv_hotspot.
TYPES: BEGIN OF ty_example,
aufnr TYPE afko-aufnr, "Process order no
plnbez TYPE afko-plnbez, "material no
matnr TYPE mara-matnr, "material no
maktx TYPE makt-maktx, "material name
charg TYPE afpo-charg, "charge no
igmng TYPE afko-igmng, "quantitiy
sbmeh TYPE afko-sbmeh, "unit
END OF ty_example.
TABLES: afko, afpo.
DATA: gt_example TYPE TABLE OF ty_example,
wa_example TYPE ty_example.
SELECT-OPTIONS order_no FOR afko-aufnr.
TYPE-POOLS: slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_layout TYPE slis_layout_alv.
PERFORM selectdata.
PERFORM regularizeview.
PERFORM catalog.
PERFORM showreport.
FORM selectdata.
SELECT
afko~aufnr
afko~plnbez
mara~matnr
makt~maktx
afpo~charg
afko~igmng
afko~sbmeh
INTO CORRESPONDING FIELDS OF TABLE gt_example UP TO 30 ROWS
FROM afko
INNER JOIN afpo ON afpo~aufnr = afko~aufnr
INNER JOIN mara ON mara~matnr = afko~plnbez
INNER JOIN makt ON makt~matnr = mara~matnr
WHERE afko~aufnr IN order_no.
ENDFORM.
FORM regularizeview.
gd_layout-colwidth_optimize = 'X'.
gd_layout-zebra = 'X'.
ENDFORM.
FORM catalog.
REFRESH fieldcat.
fieldcat-fieldname = 'AUFNR'.
fieldcat-seltext_m = 'Order No'.
fieldcat-col_pos = 0.
fieldcat-outputlen = 5.
fieldcat-emphasize = 'X'.
fieldcat-key = 'X'.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
********************************************************
fieldcat-fieldname = 'MATNR'.
fieldcat-seltext_m = 'Material No'.
fieldcat-col_pos = 1.
fieldcat-outputlen = 10.
fieldcat-hotspot = 'X'.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
********************************************************
fieldcat-fieldname = 'MAKTX'.
fieldcat-seltext_m = 'Material Name'.
fieldcat-col_pos = 2.
fieldcat-outputlen = 40.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
********************************************************
fieldcat-fieldname = 'CHARG'.
fieldcat-seltext_m = 'Charge No'.
fieldcat-col_pos = 3.
fieldcat-outputlen = 10.
fieldcat-hotspot = 'X'.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
********************************************************
fieldcat-fieldname = 'IGMNG'.
fieldcat-seltext_m = 'Quantity'.
fieldcat-col_pos = 4.
fieldcat-outputlen = 5.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
********************************************************
fieldcat-fieldname = 'SBMEH'.
fieldcat-seltext_m = 'Unit'.
fieldcat-col_pos = 5.
fieldcat-outputlen = 5.
APPEND fieldcat TO fieldcat.
CLEAR fieldcat.
ENDFORM.
FORM showreport.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = 'Example Report'
IS_LAYOUT = gd_layout
IT_FIELDCAT = fieldcat[]
TABLES
t_outtab = gt_example[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
2020 Jan 10 1:46 PM
Hi Zynp 01,
you need to do two things here.
first you need to pass the below parameters in 'REUSE_ALV_GRID_DISPLAY'
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'Example Report'
is_layout = gd_layout
it_fieldcat = fieldcat[]
TABLES
t_outtab = gt_example[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
then you need to put the code as below in the form.
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'CHARG'.
READ TABLE gt_example INTO data(gs_example) index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD gs_example-matnr.
SET PARAMETER ID 'CHA' FIELD rs_selfield-value.
CALL TRANSACTION 'MSC3N' AND SKIP FIRST SCREEN.
WHEN OTHERS.
ENDCASE.
ENDFORM.
2020 Jan 10 1:33 PM
Hi zynp,
You just have to add a call of your T-CODE.
set parameter id 'MAT' field gt_example-matnr.
call transaction 'MM03' and SKIP FIRST SCREEN.
Hope it will be helpful.
KR,
OHA.
2020 Jan 10 1:40 PM
Dear oussama.hadouch thank you for your attention,
when I add these two lines to my code a red error says:
""GT_EXAMPLE" is a table without a header line and therefore has no component called "MATNR"."
Then
I changed GT_EXAMPLE to a table with header line and wrote:
form callscreen.
set parameter id 'MAT' field gt_example-matnr.
call transaction 'MM03' and SKIP FIRST SCREEN.
ENDFORM.
and nothing happened.
2020 Jan 10 1:46 PM
Hi Zynp 01,
you need to do two things here.
first you need to pass the below parameters in 'REUSE_ALV_GRID_DISPLAY'
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'Example Report'
is_layout = gd_layout
it_fieldcat = fieldcat[]
TABLES
t_outtab = gt_example[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
then you need to put the code as below in the form.
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'CHARG'.
READ TABLE gt_example INTO data(gs_example) index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD gs_example-matnr.
SET PARAMETER ID 'CHA' FIELD rs_selfield-value.
CALL TRANSACTION 'MSC3N' AND SKIP FIRST SCREEN.
WHEN OTHERS.
ENDCASE.
ENDFORM.
2020 Jan 10 1:53 PM
Dear ebenezer.munnangi thank you for your attention,
Your advice worked
thank you so much
2020 Jan 10 2:02 PM
2020 Jan 10 1:51 PM
You can follow the instruction ebenezer.munnangi which are correct.
Kr,
OHA.