Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

call transaction.

Former Member
0 Likes
1,812

hi guru's

my problem is:

on alv grid, if i choose a material no, it transfers to the transaction code. now the material no is copied t the trn code.

in trn code, some views should be automatically selected for the corresponding matno., the initial screen of the trn should be skipped.

please guide me tru the steps.

some part of my prog:

----


FORM at_user_command USING fp_ucom TYPE sy-ucomm

fp_selfield TYPE slis_selfield. "#EC *

CASE fp_ucom.

WHEN '&IC1'.

READ TABLE i_makt INTO wa_final

INDEX fp_selfield-tabindex.

IF sy-subrc EQ c_0.

SET PARAMETER ID 'MAT' FIELD wa_final-matnr.

  • CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.*

ENDIF.

WHEN OTHERS.

MESSAGE i009.

ENDCASE.

ENDFORM. "at_user_command.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,747

Consider using BDC recording to select the views.

plz give me detailed descr as iam new t abap.

thnks.

12 REPLIES 12
Read only

Former Member
0 Likes
1,747

Hi

I did got same requirement here is my program. really sorry cant explain but that will be helpful.

you first find out view sequence then select from them that thing i have done in it.

&----


*& Report Z11VIVEKPROGRAM30 *

*& *

&----


*& *

*& *

&----


report z11vivekprogram30 message-id z11va0816

.

type-pools : slis.

----


  • TABLES DECLARATION *

----


tables mara.

----


  • TYPES *

----


types : begin of t_final,

v_box type c,

v_lights type c,

matnr type matnr, " MATERIAL NUMBER.

mtart type mtart, " MATERIAL TYPE.

maktx type maktx, " MATERIAL DESCRIPTION.

meins type meins, " UNIT OF MEASUREMENT.

werks type ewerk,

verpr type verpr,

stprs type stprs,

end of t_final.

----


  • TABLES DECLARATION FOR LONG TEXT *

----


" SAP SCRIPT TEXT FILE HEADER TABLE

tables: thead , ssm_cust ,tline.

tables : t130m, t134 , t133a.

types: begin of struct_lines,

tdformat type tdformat, " tag column

tdline type tdline, " text column

end of struct_lines.

data: wa_lines type struct_lines.

data : wa_fieldcat1 type slis_fieldcat_alv.

data: kstatus like t130m-pstat,

hstatus like t130m-pstat,

tkstatus like t130m-pstat,

bildsequenz like t133a-bilds,

berecht_akt(2) type c.

data: begin of ztab_new occurs 30.

data: bildsequenz1 like t133a-bilds.

include structure mbildtab.

data: end of ztab_new.

clear t134.

********************************************

  • WORK AREA

********************************************

data:wa_final type t_final.

*&---work area for layout

data wa_layout type slis_layout_alv.

********************************************

  • INTERNAL TABLES

********************************************

data:it_final type standard table of t_final.

*****for LONG TEXT catalog

data : it_lines type standard table of tline.

data : gt_bild type standard table of mbildtab with header line.

data : wa_bild type mbildtab.

*****for LONG TEXT catalog

data : it_long type standard table of tline with header line.

data : it_long1 type standard table of tline with header line.

*****for BDC

data: it_tab like bdcdata occurs 0 with header line.

********************************************

  • VARIABLES

********************************************

data: d_id like thead-tdid.

data: d_lang like thead-tdspras.

data: d_nm like thead-tdname.

data: d_obj like thead-tdobject.

data: v_progname like sy-repid.

data: v_gridtitle type lvc_title.

data: val1,

val2.

  • DATA DECLARATION FOR THE CATALOGS

********************************************

data: i_fieldcat type slis_t_fieldcat_alv,

i_fieldcat1 type slis_t_fieldcat_alv,

*&---Internal table for the sorting sequence.

i_sortinfo type slis_t_sortinfo_alv,

*&---Internal table for the event catalog.

i_eventcat type slis_t_event,

*&---Internal table for the top of page event

i_listheader type slis_t_listheader.

********************************************

  • SELECTION SCREEN

********************************************

selection-screen begin of block v1 with frame.

select-options : s_matnr for wa_final-matnr.

selection-screen end of block v1.

selection-screen begin of block v2 with frame title text-101.

parameters: rb1 radiobutton group rad1, "Grid

rb2 radiobutton group rad1 . "List

selection-screen end of block v2.

********************************************

  • SELECTION-SCREEN VALIDATIONS

********************************************

at selection-screen.

select matnr into wa_final-matnr

from mara

where matnr in s_matnr.

exit.

endselect.

if sy-subrc <> 0.

message e001.

endif.

********************************************

  • INITIALIZATION EVENT

********************************************

initialization.

v_progname = sy-repid.

********************************************

val1 = 'X'.

val2 = 'A'.

************************************************************************

  • START-OF-SELECTION EVENT *

************************************************************************

start-of-selection.

***************************************************************************

*Internal table is used to save the data for different types of texts

**************************************************************************

  • FUNCTION-POPULATING TABLE.

perform get_table tables it_final s_matnr.

  • FUNCTION-PRINTING LONG TEXT.

perform p_lights.

break-point.

  • PREPARE FIELDCATALOG FOR THE MAIN REPORT.

perform zf_build_fieldcat using i_fieldcat.

  • MODIFY the records IN the internal TABLE for the traffic lights.

  • perform zf_modify_final.

  • FUNCTION FOR EVENT CALLING.

perform zf_eventcat using i_eventcat.

  • FUNCTION FOR TOP OF PAGE EVENT.

perform zf_build_listheader using i_listheader.

  • FUNCTION FOR BUILDING LAYOUT.

perform zf_layout.

  • FUNCTION FOR GRID TITLE.

perform zf_build_grid_title.

  • IF p_rb1 RADIO button (ALV GRID) IS selected .

if rb1 is not initial.

  • DISPLAY ALV GRID.

perform zf_display_alv_grid.

else.

  • DISPLAY ALV LIST.

perform zf_display_alv_list.

endif.

end-of-selection.

&----


*& Form get_TABLE

&----


  • text

----


  • -->P_IT_FINAL text

  • -->P_S_MATNR text

----


form get_table tables p_it_final structure wa_final

p_s_matnr structure s_matnr.

select matnr

meins

mtart

into corresponding fields of table it_final

from mara

where matnr in s_matnr.

sort it_final by matnr.

loop at it_final into wa_final.

select single maktx into wa_final-maktx

from makt

where matnr = wa_final-matnr.

select single verpr stprs into (wa_final-verpr,

wa_final-stprs)

from mbew

where matnr = wa_final-matnr.

modify it_final from wa_final transporting maktx.

endloop.

endform. " get_TABLE

&----


*& Form zf_build_fieldcat

&----


  • text

----


  • -->P_I_FIELDCAT text

----


form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.

data:l_fieldcat type slis_fieldcat_alv.

clear l_fieldcat.

l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.

l_fieldcat-fieldname = 'V_LIGHTS'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

l_fieldcat-emphasize = 'C311'. " COLOR OF THIS COLUMN.

l_fieldcat-just = 'C'. " FOR JUSTIFICATION.

l_fieldcat-outputlen = 7.

" TO DEFINE OUTPUT LENGTH OF THE COLUMN.

append l_fieldcat to p_i_fieldcat.

l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.

l_fieldcat-fieldname = 'V_BOX'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

l_fieldcat-emphasize = 'C311'. " COLOR OF THIS COLUMN.

l_fieldcat-just = 'C'. " FOR JUSTIFICATION.

l_fieldcat-outputlen = 2.

l_fieldcat-checkbox = 'X'.

" TO DEFINE OUTPUT LENGTH OF THE COLUMN.

append l_fieldcat to p_i_fieldcat.

l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.

l_fieldcat-fieldname = 'MATNR'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

l_fieldcat-emphasize = 'C311'. " COLOR OF THIS COLUMN.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION.

l_fieldcat-key = 'X'.

    • L_FIELDCAT-HOTSPOT = 'X'.

    • " MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-seltext_l = 'Material no.'. " LONG TEXT FOR HEADER.

l_fieldcat-seltext_m = 'Material no.'. " MEDIUM TEXT FOR HEADER.

l_fieldcat-seltext_s = 'Mat. No.'. " SHORT TEXT FOR HEADER.

l_fieldcat-ref_tabname = 'VBAK'.

l_fieldcat-outputlen = 18.

" TO DEFINE OUTPUT LENGTH OF THE COLUMN.

append l_fieldcat to p_i_fieldcat.

l_fieldcat-col_pos = '4'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'MTART'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Material Type'." long text for header.

l_fieldcat-seltext_m = 'Material Type'. " medium text for header.

l_fieldcat-seltext_s = 'Mat. Type'. " sort text for header.

l_fieldcat-outputlen = 20. " SET THE output length.

l_fieldcat-ref_tabname = 'VBAK'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'MAKTX'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Description'." long text for header.

l_fieldcat-seltext_m = 'Description'. " medium text for header.

l_fieldcat-seltext_s = 'Descrip.'. " sort text for header.

l_fieldcat-outputlen = 20. " SET THE output length.

l_fieldcat-ref_tabname = 'MAKT'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '6'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'MEINS'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'IT_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'UOM'." long text for header.

l_fieldcat-seltext_m = 'UOM'. " medium text for header.

l_fieldcat-seltext_s = 'UOM'. " sort text for header.

l_fieldcat-outputlen = 4. " SET THE output length.

l_fieldcat-ref_tabname = 'MARA'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

endform. " zf_build_fieldcat

&----


*& Form zf_build_grid_title

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_build_grid_title .

v_gridtitle = 'List of Material'.

endform. " zf_build_grid_title

&----


*& Form zf_build_listheader

&----


  • text

----


  • -->P_I_LISTHEADER text

----


form zf_build_listheader using p_i_listheader type slis_t_listheader.

data: l_listheader type slis_listheader.

refresh p_i_listheader.

clear l_listheader.

l_listheader-typ = 'H'. "Header

l_listheader-key = 'FCIL,INDIA'. "Ignored for "Header" Type

l_listheader-info = 'FUJITSU CONSULTING INDIA LIMITED'.

append l_listheader to p_i_listheader.

l_listheader-typ = 'S'.

l_listheader-key = 'DATE'.

l_listheader-info = sy-datum.

append l_listheader to p_i_listheader.

clear l_listheader.

l_listheader-typ = 'A'.

l_listheader-key = 'COMMENT'."Ignored for "action" Type

l_listheader-info = 'Possibilities are infinite'.

append l_listheader to p_i_listheader.

endform. " zf_build_listheader

&----


*& Form zf_display_alv_grid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

&----


form zf_display_alv_grid .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_progname

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = v_gridtitle

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = i_eventcat

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_final

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. " zf_display_alv_grid

&----


*& Form zf_display_alv_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_display_alv_list .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_progname

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

is_layout = wa_layout

it_fieldcat = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

  • I_SAVE =

  • IS_VARIANT =

it_events = i_eventcat

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_final

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. " zf_display_alv_list

&----


*& Form zf_eventcat

&----


  • text

----


  • -->P_I_EVENTCAT text

----


form zf_eventcat using p_i_eventcat type slis_t_event.

data l_eventcat type slis_alv_event.

clear l_eventcat.

*Get all the events.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = p_i_eventcat

exceptions

list_type_wrong = 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.

  • TOP-OF-PAGE FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_top_of_page.

if sy-subrc = 0.

move 'ZF_TOP_OF_PAGE' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

endif.

  • PF_STATUS_SET FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_pf_status_set.

if sy-subrc = 0.

move 'ZF_PF_STATUS_SET' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

.

endif.

  • USER_COMMAND FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_user_command.

if sy-subrc = 0.

move 'ZF_USER_COMMAND' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

endif.

endform. " zf_eventcat

----


*FORM TOP-OF-PAGE.

----


form zf_top_of_page.

*This FM is responsible for formatting the header information

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = i_listheader

i_logo = 'ENJOYSAP_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

endform. "TOP-OF-PAGE

----


*FORM PF_STATUS_SET.

----


form zf_pf_status_set using rt_extab type slis_t_extab.

set pf-status 'ALV_MENU1'.

endform. "SET_PF_STATUS

----


  • FORM USER_COMMAND.

----


form zf_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when 'MM03'.

read table it_final into wa_final index rs_selfield-tabindex.

set parameter id 'MAT' field wa_final-matnr.

call transaction 'MM03' and skip first screen.

----


  • WHEN LONG TEXT IS TO BE DISPLAYED / EDITED.

----


when 'DISPLAY'. "for hotspot with MATNR.

data: v_mat type matnr.

if rs_selfield-fieldname = 'MATNR'.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = rs_selfield-value

importing

output = v_mat.

  • TO RETRIVE DATA FOR LONG TEXT DISPLAY.

d_nm = v_mat.

d_lang = 'EN'.

d_id = 'GRUN'.

d_obj = 'MATERIAL'.

call function 'READ_TEXT'

exporting

  • CLIENT = SY-MANDT

id = d_id

language = d_lang

name = d_nm

object = d_obj

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = it_long

exceptions

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

others = 8

.

if sy-subrc = 0.

refresh i_fieldcat1.

clear wa_fieldcat1.

wa_fieldcat1-col_pos = '1'. "POSITION OF THE COLUMN

wa_fieldcat1-fieldname = 'TDLINE'. "FIELD NAME

wa_fieldcat1-tabname = 'IT_long1'. "NAME OF INTERNAL TABLE

  • WA_FIELDCAT-ref_tabname = 'MARA'. "FOR REFERENCE

  • WA_FIELDCAT-key = 'X'. "MAKING FIELD AS KEY FIELD

wa_fieldcat1-emphasize = 'C210'.

  • WA_FIELDCAT1-EDIT_MASK = 'X'.

wa_fieldcat1-outputlen = 72. "OUTPUT LENGTH FOR FIELD

wa_fieldcat1-seltext_s = 'LONG TEXT'. "SHORT TEXT FOR HEADER

wa_fieldcat1-edit = 'X'.

append wa_fieldcat1 to i_fieldcat1. "APPEND NEW LINE AT THE END

clear wa_fieldcat1.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_progname

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE = V_GRIDTITLE

  • I_GRID_SETTINGS =

  • IS_LAYOUT = WA_LAYOUT

it_fieldcat = i_fieldcat1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = I_EVENTCAT

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_long

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.

endif.

endif.

********************************************

  • WHILE EDITING OR ADDING LONG TEXT

********************************************

when 'EDIT'.

refresh i_fieldcat1.

clear wa_fieldcat1.

clear it_long.

wa_fieldcat1-col_pos = '1'. " position of the column

wa_fieldcat1-fieldname = 'TDLINE'.

wa_fieldcat1-tabname = 'IT_LONG'.

wa_fieldcat1-key = ' '. " column with key-color

wa_fieldcat1-just = 'L'. " (R)ight (L)eft (C)ent.

wa_fieldcat1-edit = 'X'.

wa_fieldcat1-input = 'X'.

wa_fieldcat1-seltext_l = 'LONG TEXT'. " long key word

wa_fieldcat1-seltext_m = 'LONG TEXT.'. " middle key word

wa_fieldcat1-seltext_s = 'TEXT'. " short key word

wa_fieldcat1-intlen = 132.

wa_fieldcat1-outputlen = 132.

append wa_fieldcat1 to i_fieldcat1. "APPEND NEW LINE AT THE END

clear wa_fieldcat1.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_progname

  • I_CALLBACK_PF_STATUS_SET = 'ZF '

  • I_CALLBACK_USER_COMMAND = 'ZF_USER_COMMAND_1 '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_long

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.

  • BDC ON MMO2

loop at it_final into wa_final where matnr = rs_selfield-value.

clear it_long.

loop at it_long.

select single * from t134 where mtart = wa_final-mtart.

  • FOR GETTING SCREEN REFERENCE FIELD

call function 'MATERIAL_INIT'

exporting

tcode = 'MM02'

kz_berprf = 'X'

importing

it130m = t130m

tkstatus = tkstatus

exceptions

no_authority = 1

wrong_call = 2

kstatus_empty = 3

tkstatus_empty = 4

aktyp_tcode_mismatch = 5

tcode_not_found = 6

material_article_mismatch = 7

others = 8.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • FOR GETTING SEQUENCE

call function 'BILDSEQUENZ_IDENTIFY'

exporting

materialart = wa_final-mtart

tcode_ref = t130m-trref

importing

bildsequenz = bildsequenz.

clear gt_bild.

  • FOR GETTING TABLE WITH DYTXT AND ITS ID

call function 'SELECTION_VIEWS_FIND'

exporting

bildsequenz = bildsequenz

pflegestatus = t134-pstat "tkstatus

tables

bildtab = gt_bild

exceptions

call_wrong = 1

empty_selection = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • STARTING BDC TABLE POPULATION

loop at gt_bild into wa_bild where dytxt = 'Basic Data 1'.

wa_bild-kzsel = 'X'.

modify gt_bild from wa_bild.

endloop.

break-point.

  • MM02 FIRST SCREEN----------------------------------

perform bdc_dynpro using 'SAPLMGMM'

'0060'.

perform bdc_field using 'BDC_OKCODE'

'=AUSW'.

perform bdc_field using 'RMMG1-MATNR'

wa_final-matnr.

  • VIEW SELECTION--------------------------------------

perform bdc_dynpro using 'SAPLMGMM'

'0070'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

  • FIRST VIEW------------------------------------------

perform bdc_dynpro using 'SAPLMGMM'

'4004'.

perform bdc_field using 'BDC_OKCODE'

'=PB26'.

*----


perform bdc_dynpro using 'SAPLMGMM'

'4300'.

perform bdc_field using 'BDC_OKCODE'

'=LTEX'.

*----


perform bdc_dynpro using 'SAPLSTXX'

'1100'.

perform bdc_field using 'BDC_OKCODE'

'=TXVB'.

perform bdc_field using 'RSTXT-TXLINE(02)'

it_long-tdline.

*----


  • ENTERING LONG-TEXT

*----


perform bdc_dynpro using 'SAPLSTXX'

'1100'.

perform bdc_field using 'BDC_OKCODE'

'=TXBA'.

*----


perform bdc_dynpro using 'SAPLSTXX'

'4300'.

perform bdc_field using 'BDC_OKCODE'

'=BABA'.

*----


perform bdc_dynpro using 'SAPLMGMM'

'4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

*----


  • TO SAVE THE MATERIAL EDITED INFORMATION

*----


perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

*----


  • PERFORM BDC TRANSACTION.

*----


call transaction 'MM02' using it_tab mode 'A'.

endloop.

endloop.

endcase.

endform. " USER_COMMAND

&----


*& Form zf_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_layout .

clear wa_layout.

wa_layout-zebra = 'X'.

wa_layout-lights_fieldname = 'V_LIGHTS'.

wa_layout-lights_tabname = 'IT_FINAL'.

" 1, 2 or 3 for red, yellow and green respectively.

wa_layout-box_fieldname = 'V_BOX'.

wa_layout-box_tabname = 'IT_FINAL'.

wa_layout-totals_text = 'Total'.

wa_layout-subtotals_text = 'SubTotal'.

endform. " zf_layout

&----


*& Form p_lights

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form p_lights .

loop at it_final into wa_final.

data: v_mat type matnr.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = wa_final-matnr

importing

output = v_mat.

d_id = 'GRUN'.

d_lang = 'EN'.

d_nm = v_mat.

d_obj = 'MATERIAL'.

call function 'READ_TEXT'

exporting

  • CLIENT = SY-MANDT

id = d_id

language = d_lang

name = d_nm

object = d_obj

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = it_long

exceptions

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

others = 8

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

if sy-subrc = 0.

read table it_long index 1 into wa_lines.

if wa_lines-tdline = 'IMPORTANT'.

wa_final-v_lights = '3'.

modify it_final from wa_final.

else.

wa_final-v_lights = '2'.

modify it_final from wa_final.

endif.

else.

wa_final-v_lights = '1'.

modify it_final from wa_final.

endif.

endloop.

endform. " p_l_text

&----


*& Form bdc_transaction

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_transaction .

call function 'BDC_INSERT'

exporting

tcode = 'MM02'

tables

dynprotab = it_tab.

endform. " bdc_transaction

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear it_tab.

it_tab-program = program.

it_tab-dynpro = dynpro.

it_tab-dynbegin = 'X'.

append it_tab.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

clear it_tab.

it_tab-fnam = fnam.

it_tab-fval = fval.

append it_tab.

endform.

plz reward if useful

vivek

Read only

Former Member
0 Likes
1,748

Consider using BDC recording to select the views.

Read only

0 Likes
1,747

i dont know how to use bdc. plz guide me with steps

Read only

0 Likes
1,747

BDC recording

Tran code SM35

Select "Recording"

Select "New Recording"

Enter a name in Recording Field

Enter MM03 in Transactoin Code

Select Start Recording

Enter your material Number

Hit "Enter" key

Select your views

Hit "Enter" key

Green Arrow (PF3) out until you get to Transaction recorder

SAVE

Green Arrow (PF3)

Select your recording

Select Program button

Enter a name for you program

Select "Transfer from recording"

and then the Green Check

Fill in Title etc

then Source code Button

This will generate a program that if run by itself will mimic your session.

You will need to select the parts of it and parts of the include into your program with field filled in. Put the pieces into your orginal code. Use the Call Transaction option in the generated program to see the fields you will need.

This process can take some practice to get used to.

You will Need these fields in your target program.


*_________________________________________________ BDC Data Area Start
DATA:
  session                 TYPE c,
  group(12)               TYPE c,
  user                    LIKE sy-uname,
  keep                    TYPE c,
  holddate                LIKE sy-datum,
  smalllog                TYPE c,
  ctumode                 TYPE c,
  cupdate                 TYPE c,
  e_group(12)             TYPE c,
  e_user                  LIKE sy-uname,
  e_keep                  TYPE c,
  e_hdate                 LIKE sy-datum,
  nodata                  TYPE c.
*----------------------------------------------------------------------*
*   data definition
*----------------------------------------------------------------------*
*       Batchinputdata of single transaction
DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*       messages of call transaction
DATA:   messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
*       error session opened (' ' or 'X')
DATA:   e_group_opened.
*       message texts
TABLES: t100.

Then somewhere you will call the form


*&---------------------------------------------------------------------*
*&      Form  BCD_SCRIPT
*&---------------------------------------------------------------------*
FORM bcd_script.
  ctumode = 'E'.
*  ctumode = 'N'.
*  ctumode = 'A'.

  nodata  = '/'.

start-of-selection.

perform open_group.
perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field       using 'BDC_CURSOR' 'RMMG1-MATNR'.
perform bdc_field       using 'BDC_OKCODE' '=ENTR'.
perform bdc_field       using 'RMMG1-MATNR' material_number.
perform bdc_dynpro      using 'SAPLMGMM' '0070'.
perform bdc_field       using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(03)'.
perform bdc_field       using 'BDC_OKCODE' '=ENTR'.
* Code is selecting your views here
perform bdc_field       using 'MSICHTAUSW-KZSEL(01)' 'X'.
perform bdc_field       using 'MSICHTAUSW-KZSEL(02)' 'X'.
perform bdc_field       using 'MSICHTAUSW-KZSEL(03)' 'X'.
* Code stops selecting your views here
perform bdc_dynpro      using 'SAPLMGMM' '0080'.
perform bdc_field       using 'BDC_OKCODE' '=BOZO'.
* this will Cause error and BDC to stop processing
perform bdc_transaction using 'MM03'.

perform close_group.

You will also need these FORMS in your target program


*----------------------------------------------------------------------*
*   create batchinput session                                          *
*   (not for call transaction using...)                                *
*----------------------------------------------------------------------*
FORM open_group.
  IF session = 'X'.
    SKIP.
    WRITE: /(20) 'Create group'(i01), group.
    SKIP.
*   open batchinput group
    CALL FUNCTION 'BDC_OPEN_GROUP'
         EXPORTING
              client   = sy-mandt
              group    = group
              user     = user
              keep     = keep
              holddate = holddate.
    WRITE: /(30) 'BDC_OPEN_GROUP'(i02),
            (12) 'returncode:'(i05),
                 sy-subrc.
  ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
*   end batchinput session                                             *
*   (call transaction using...: error session)                         *
*----------------------------------------------------------------------*
FORM close_group.
  IF session = 'X'.
*   close batchinput group
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /(30) 'BDC_CLOSE_GROUP'(i04),
            (12) 'returncode:'(i05),
                 sy-subrc.
  ELSE.
    IF e_group_opened = 'X'.
      CALL FUNCTION 'BDC_CLOSE_GROUP'.
      WRITE: /.
      WRITE: /(30) 'Fehlermappe wurde erzeugt'(i06).
      e_group_opened = ' '.
    ENDIF.
  ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
*        Start new transaction according to parameters                 *
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
  DATA: l_mstring(480).
  DATA: l_subrc LIKE sy-subrc.
* batch input session
  IF session = 'X'.
    CALL FUNCTION 'BDC_INSERT'
         EXPORTING
              tcode     = tcode
         TABLES
              dynprotab = bdcdata.
    IF smalllog <> 'X'.
      WRITE: / 'BDC_INSERT'(i03),
               tcode,
               'returncode:'(i05),
               sy-subrc,
               'RECORD:',
               sy-index.
    ENDIF.
* call transaction using
  ELSE.
    REFRESH messtab.
    CALL TRANSACTION tcode USING bdcdata
                     MODE   ctumode
                     UPDATE cupdate
                     MESSAGES INTO messtab.
    l_subrc = sy-subrc.
    IF smalllog <> 'X'.
      WRITE: / 'CALL_TRANSACTION',
               tcode,
               'returncode:'(i05),
               l_subrc,
               'RECORD:',
               sy-index.
      LOOP AT messtab.
        SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
                                  AND   arbgb = messtab-msgid
                                  AND   msgnr = messtab-msgnr.
        IF sy-subrc = 0.
          l_mstring = t100-text.
          IF l_mstring CS '&1'.
            REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
            REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
            REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
            REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
          ELSE.
            REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
          ENDIF.
          CONDENSE l_mstring.
          WRITE: / messtab-msgtyp, l_mstring(250).
        ELSE.
          WRITE: / messtab.
        ENDIF.
      ENDLOOP.
      SKIP.
    ENDIF.
** Erzeugen fehlermappe ************************************************
    IF l_subrc <> 0 AND e_group <> space.
      IF e_group_opened = ' '.
        CALL FUNCTION 'BDC_OPEN_GROUP'
             EXPORTING
                  client   = sy-mandt
                  group    = e_group
                  user     = e_user
                  keep     = e_keep
                  holddate = e_hdate.
        e_group_opened = 'X'.
      ENDIF.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                tcode     = tcode
           TABLES
                dynprotab = bdcdata.
    ENDIF.
  ENDIF.
  REFRESH bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  APPEND bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  IF fval <> nodata.
    CLEAR bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    APPEND bdcdata.
  ENDIF.
ENDFORM.

Edited by: Paul Chapman on Mar 11, 2008 2:08 PM

Edited by: Paul Chapman on Mar 11, 2008 2:17 PM

Read only

Former Member
0 Likes
1,747

Hi, Fill BDCDATA table with few views selected and use it in Call transaction. Call transaction in 'E' mode.

Read only

0 Likes
1,747

Hi ,

First go to MM03 ,enter one material number,

then press 'select view ' tab and select the basic data view or any other view .then click on Default button on same window.

and check the checkbox on the same screen,

then your problem will be solved.

Hope it helps.

Revert for any clarification.

reward points if helpful.

Regards,

Talwinder

Read only

0 Likes
1,747

DATA : li_bdc TYPE STANDARD TABLE OF bdcdata.

DATA : ls_opt TYPE ctu_params.

CLEAR ls_opt.

REFRESH li_bdc.

MOVE 'E' TO ls_opt-dismode.

MOVE 'X' TO ls_opt-nobinpt.

PERFORM insert_line_bdcdata TABLES li_bdc

USING :

'SAPLMGMM' '0060' 'X' ' ' ' ' ,

' ' ' ' ' ' 'BDC_OKCODE' '/00' ,

' ' ' ' ' ' 'RMMG1-MATNR' ls_ven_alv-pn ,

'SAPLMGMM' '0070' 'X' ' ' ' ' ,

' ' ' ' ' ' 'BDC_OKCODE' '=SELA' ,

'SAPLMGMM' '0070' 'X' ' ' ' ' ,

' ' ' ' ' ' 'BDC_OKCODE' '=ENTR' .

  • MM03

CALL TRANSACTION 'MM03' USING li_bdc

OPTIONS FROM ls_opt.

&----


*& Form insert_line_bdcdata

&----


  • Prepare the internal table for the Batch input

----


  • -->PI_BDC Internal table which contains the batch sequence

  • -->PW_PROGRAM BDC module pool

  • -->PW_DYNPRO BDC Screen number

  • -->PW_DYNBEGIN BDC screen start

  • -->PW_FNAM Field name

  • -->PW_FVAL BDC field value

----


FORM insert_line_bdcdata TABLES pi_bdc TYPE bdcdata_tab

USING pw_program TYPE any

pw_dynpro TYPE any

pw_dynbegin TYPE any

pw_fnam TYPE any

pw_fval TYPE any.

DATA : ls_bdc TYPE bdcdata.

CLEAR ls_bdc.

MOVE pw_program TO ls_bdc-program.

MOVE pw_dynpro TO ls_bdc-dynpro.

MOVE pw_dynbegin TO ls_bdc-dynbegin.

MOVE pw_fnam TO ls_bdc-fnam.

MOVE pw_fval TO ls_bdc-fval.

APPEND ls_bdc TO pi_bdc.

ENDFORM. "insert_line_bdcdata

Read only

0 Likes
1,747

i should not touch the properties of the transaction.

i should code it or use some bdc for my program only.

so can u please guide me with it

regards,

chaitanya

Read only

0 Likes
1,747

Hi chaitanya,,

this way you are not altering with properties,

you are just giving default values to tha view screen,

Regards,

Talwinder

Read only

0 Likes
1,747

hi ,

ok, my work is to code or use bdc in my progrm.

if we select those default views, they will effect the view of other users of this transaction.

so i need t program it. May b using bdc's.

can u guide me.

regards,

chaitanya

Read only

Former Member
0 Likes
1,747

plz give me detailed descr as iam new t abap.

thnks.

Read only

Former Member
0 Likes
1,747

THANKS FOR UR VALUABLE HELP