ejercicios_sap.docx

Post on 28-Oct-2015

140 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

report zReport1.tables: lfa1.

*Pantalla de Selecciónparameters: c1 like lfa1-lifnr.

*Inicio del programastart-of-selection.

select single * from lfa1 where lifnr eq c1.end-of-selection.

write: lfa1-lifnr, lfa1-name1.

initialization.c1 = '1001'.

report zReport2.tables: kna1.types: begin of it1_kna1,* INCLUDE STRUCTURE KNA1. zcliente type kna1-kunnr, land1 type kna1-land1, zname type kna1-name1, ort01 type kna1-ort01, end of it1_kna1.data: it_kna1 type standard table of it1_kna1 with header line.data: wa_kna1 type it1_kna1.data: cod_cli like kna1-kunnr.

parameters: p_cod like kna1-kunnr.

start-of-selection.

cod_cli = 'deudor07'.

perform buscar_ultimo_cliente using cod_cli.*PERFORM asignar_cliente.

*&---------------------------------------------------------------------**& Form BUSCAR_ULTIMO_CLIENTE*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form buscar_ultimo_cliente using p_codigo like kna1-kunnr.

clear: it_kna1. refresh: it_kna1. clear wa_kna1.

select kunnr land1 name1 ort01 into table it_kna1 from kna1 where kunnr = p_cod.

loop at it_kna1 into wa_kna1.

if sy-subrc = 0.

write:/5 wa_kna1-zcliente, "kunnr, 20 wa_kna1-zname.

write:/ 'cliente encontrado'. else. write: 'no cliente encontrado'. endif.

endloop.endform. " BUSCAR_ULTIMO_CLIENTE

*&---------------------------------------------------------------------**& Report YREPORTE4EMM*&*&---------------------------------------------------------------------**&

*&*&---------------------------------------------------------------------*

report no standard page heading line-size 121 line-count (5) message-id zcurso99.

tables: spfli, sflight, scarr.select-options: s_carrid for sflight-carrid, s_connid for sflight-connid, s_cdfrom for spfli-cityfrom, s_cdto for spfli-cityto.

data: begin of it_hdr occurs 0, carrid type sflight-carrid, carrname type scarr-carrname, connid type sflight-connid, cityfrom type spfli-cityfrom, airpfrom type spfli-airpfrom, cityto type spfli-cityto, airpto type spfli-airpto, end of it_hdr.

data: begin of it_dtl occurs 0, fldate type sflight-fldate, seatsmax type sflight-seatsmax, connid type sflight-connid, seatsocc type sflight-seatsocc, price type sflight-price, prec_tot type p decimals 2, por_seats type p decimals 2, end of it_dtl.

data: wa_hdr like it_hdr, wa_dtl like it_dtl.

start-of-selection.

select distinct b~carrid b~carrname a~connid c~cityfrom c~airpfrom c~cityto c~airpto into table it_hdr

from sflight as a inner join scarr as b on a~carrid = b~carrid inner join spfli as c on c~carrid = b~carrid and a~connid = c~connid where a~carrid in s_carrid and a~connid in s_connid and c~cityfrom in s_cdfrom and c~cityto in s_cdto.

sort it_hdr descending by carrid.

format color 4.

if sy-subrc eq 0. message i003.

loop at it_hdr into wa_hdr. write:/ '|',wa_hdr-carrid,' |', wa_hdr-carrname,'|', wa_hdr-connid,' |',

wa_hdr-cityfrom,'|', wa_hdr-airpfrom,' |', wa_hdr-cityto,'|', wa_hdr-airpto,' |'.

hide: wa_hdr-carrname, wa_hdr-connid, wa_hdr-connid.

uline at (108). endloop.

else. message i004. endif.

at line-selection. if sy-lsind = 1 and sy-curow > 3. select fldate seatsmax connid seatsocc price from sflight into table it_dtl where connid = wa_hdr-connid.

loop at it_dtl into wa_dtl.

wa_dtl-por_seats = wa_dtl-seatsocc * 100 / wa_dtl-seatsmax.

wa_dtl-prec_tot = wa_dtl-price * wa_dtl-seatsocc. format color 2. write:/ '|',wa_dtl-fldate,' |', wa_dtl-seatsmax,'|', wa_dtl-seatsocc,'|', wa_dtl-prec_tot,'|', wa_dtl-por_seats,'|'.

uline at (82). endloop.

endif.

top-of-page. uline. format color 3. write: '|',5 'Id ','|', 17 'Nombre',' |', 34 '#Vuelo ',' |', 53 'CdFrom',' |', 70 'AiFrom','|', 87 'CdTo',' |', 103'AiTo','|'.

uline at (108).

top-of-page during line-selection. format color 1. uline at (82). write:/ '| ', text-001, ' |'. write:/ '|' , (11) 'Aerolínea:', wa_hdr-carrname, (40) ' No.vuelo:',wa_hdr-connid, '|'.

uline . format color 4 .

write: '| ',6 'fecha',' |', 19 'Max.Asi',' |', 32 'Asi.Occ',' |', 51 'Totales',' |', 68 'Porcentaje',' |'.

uline at (82).

*&---------------------------------------------------------------------**& Report YREPORTEEMM*&*&---------------------------------------------------------------------**& Nombre: Enrique Moreno*& Fecha: 07-Dic-2011*& Descripción: Prueba de Reporte GICSA*&---------------------------------------------------------------------*

report yreporteemm.tables: trdir.

selection-screen begin of block uno with frame title text-001.parameters: r_opt01 radiobutton group rad1, r_opt02 radiobutton group rad1, r_opt03 radiobutton group rad1, r_opt04 radiobutton group rad1.

selection-screen skip.

parameters: p_opt01 radiobutton group rad2 user-command aaa, p_opt02 radiobutton group rad2, p_opt03 radiobutton group rad2, p_opt04 radiobutton group rad2.selection-screen end of block uno.

selection-screen begin of block dos with frame title text-002.select-options: s_opt1 for trdir-cnam, s_opt22 for trdir-cnam, s_opt333 for trdir-cnam, s_opt444 for trdir-cnam.

selection-screen end of block dos.

at selection-screen output.

loop at screen.*----- Option 1 if r_opt01 = 'X'. if screen-name cs 'S_OPT1'. screen-invisible = '0'. screen-input = '1'. elseif screen-name cs 'S_OPT22' or screen-name cs 'S_OPT333' or screen-name cs 'S_OPT444'.

screen-invisible = '1'. screen-input = '0'. endif.

*----- Option 2 elseif p_opt02 = 'X'. if screen-name cs 'S_OPT22'. screen-invisible = '0'. screen-input = '1'. elseif screen-name cs 'S_OPT1' or screen-name cs 'S_OPT333' or screen-name cs 'S_OPT444'.

screen-invisible = '1'. screen-input = '0'.

endif.

*----- Option 3 elseif p_opt03 = 'X'. if screen-name cs 'S_OPT333'. screen-invisible = '0'. screen-input = '1'. elseif screen-name cs 'S_OPT1' or screen-name cs 'S_OPT22' or screen-name cs 'S_OPT444'.

screen-invisible = '1'. screen-input = '0'. endif.

*----- Option 4 elseif p_opt04 = 'X'. if screen-name cs 'S_OPT444'. screen-invisible = '0'. screen-input = '1'. elseif screen-name cs 'S_OPT1' or screen-name cs 'S_OPT22' or screen-name cs 'S_OPT333'.

screen-invisible = '1'. screen-input = '0'. endif. endif. modify screen. endloop.

*&---------------------------------------------------------------------**& Report YREPORTE_ALV_EMM*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report yreporte_alv_emm.

**EJEMPLO 1

tables: scarr.

type-pools: slis. "ALV Declarations*Data Declarationtypes: begin of t_scarr, mandt type scarr-mandt, carrid type scarr-carrid, carrname type scarr-carrname, currcode type scarr-currcode, url type scarr-url, end of t_scarr.

data: it_scarr type standard table of t_scarr initial size 0, wa_scarr type t_scarr.

*ALV data declarationsdata: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid.

start-of-selection.start-of-selection.

perform data_retrieval.

perform build_fieldcatalog.perform build_layout.perform display_alv_report.

*&---------------------------------------------------------------------**& Form BUILD_FIELDCATALOG*&---------------------------------------------------------------------** Build Fieldcatalog for ALV Report*----------------------------------------------------------------------*form build_fieldcatalog.

fieldcatalog-fieldname = 'MANDT'. fieldcatalog-seltext_m = 'Purchase Order'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'. fieldcatalog-do_sum = 'X'. fieldcatalog-no_zero = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'CARRID'. fieldcatalog-seltext_m = 'PO Item'. fieldcatalog-col_pos = 1. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'CARRNAME'. fieldcatalog-seltext_m = 'Status'. fieldcatalog-col_pos = 2. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'CURRCODE'. fieldcatalog-seltext_m = 'Item change date'. fieldcatalog-col_pos = 3. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'URL'. fieldcatalog-seltext_m = 'Material Number'. fieldcatalog-col_pos = 4. append fieldcatalog to fieldcatalog. clear fieldcatalog.endform. " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------**& Form BUILD_LAYOUT*&---------------------------------------------------------------------** Build layout for ALV grid report*----------------------------------------------------------------------*form build_layout. gd_layout-no_input = 'X'. gd_layout-colwidth_optimize = 'X'. gd_layout-totals_text = 'Totals'(201). gd_layout-totals_only = 'X'. gd_layout-f2code = 'DISP'. "Sets fcode for when double "click(press f2) gd_layout-zebra = 'X'. gd_layout-group_change_edit = 'X'. gd_layout-header_text = 'helllllo'.endform. " BUILD_LAYOUT

*&---------------------------------------------------------------------**& Form DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------** Display report using ALV grid*----------------------------------------------------------------------*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'* i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[]* it_special_groups = gd_tabgroup* IT_EVENTS = GT_XEVENTS i_save = 'X'* is_variant = z_template

tables t_outtab = it_scarr 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 DATA_RETRIEVAL*&---------------------------------------------------------------------** Retrieve data form EKPO table and populate itab it_ekko*----------------------------------------------------------------------*form data_retrieval.

select mandt carrid carrname currcode url up to 20 rows from scarr into table it_scarr.endform. " DATA_RETRIEVAL

*&---------------------------------------------------------------------**& Module Pool Y_MODULEPOOL_EMM*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

program y_modulepool_emm.

tables: usr21, adrp.*&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_9000 input.

case sy-ucomm.*Abandona la Dynpro actual when 'SALIR'. set screen 0. leave screen.

when 'BUSCAR'. select single * from usr21 where bname = usr21-bname.

if sy-subrc = 0. select single * from adrp where persnumber = usr21-persnumber.

if sy-subrc ne 0. adrp-name_text = 'El usuario no existe'. endif. else. adrp-name_text = 'El usuario no existe'. endif.endcase.

endmodule. " USER_COMMAND_9000 INPUT

*&---------------------------------------------------------------------**& Report ZALV_GRID*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zalv_grid.

tables: ekko.

type-pools: slis. "ALV Declarations*Data Declaration*----------------types: begin of t_ekko, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, statu type ekpo-statu, aedat type ekpo-aedat, matnr type ekpo-matnr, menge type ekpo-menge, meins type ekpo-meins, netpr type ekpo-netpr, peinh type ekpo-peinh, end of t_ekko.

data: it_ekko type standard table of t_ekko initial size 0, wa_ekko type t_ekko.

*ALV data declarationsdata: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid, gt_events type slis_t_event, gd_prntparams type slis_print_alv.

*************************************************************************Start-of-selection.start-of-selection.

perform data_retrieval.perform build_fieldcatalog.perform build_layout.perform build_events.perform build_print_params.perform display_alv_report.

*&---------------------------------------------------------------------**& Form BUILD_FIELDCATALOG*&---------------------------------------------------------------------*

* Build Fieldcatalog for ALV Report*----------------------------------------------------------------------*form build_fieldcatalog.

* There are a number of ways to create a fieldcat.* For the purpose of this example i will build the fieldcatalog manualy* by populating the internal table fields individually and then* appending the rows. This method can be the most time consuming but can* also allow you more control of the final product.

* Beware though, you need to ensure that all fields required are* populated. When using some of functionality available via ALV, such as* total. You may need to provide more information than if you were* simply displaying the result* I.e. Field type may be required in-order for* the 'TOTAL' function to work.

fieldcatalog-fieldname = 'EBELN'. fieldcatalog-seltext_m = 'Purchase Order'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'.* fieldcatalog-do_sum = 'X'.* fieldcatalog-no_zero = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'. fieldcatalog-seltext_m = 'PO Item'. fieldcatalog-col_pos = 1. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'. fieldcatalog-seltext_m = 'Status'. fieldcatalog-col_pos = 2. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'. fieldcatalog-seltext_m = 'Item change date'. fieldcatalog-col_pos = 3. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'. fieldcatalog-seltext_m = 'Material Number'. fieldcatalog-col_pos = 4. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'. fieldcatalog-seltext_m = 'PO quantity'. fieldcatalog-col_pos = 5. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'. fieldcatalog-seltext_m = 'Order Unit'. fieldcatalog-col_pos = 6. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'. fieldcatalog-seltext_m = 'Net Price'. fieldcatalog-col_pos = 7. fieldcatalog-outputlen = 15. fieldcatalog-datatype = 'CURR'. append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'. fieldcatalog-seltext_m = 'Price Unit'. fieldcatalog-col_pos = 8. append fieldcatalog to fieldcatalog. clear fieldcatalog.endform. " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------**& Form BUILD_LAYOUT*&---------------------------------------------------------------------** Build layout for ALV grid report*----------------------------------------------------------------------*form build_layout. gd_layout-no_input = 'X'. gd_layout-colwidth_optimize = 'X'. gd_layout-totals_text = 'Totals'(201).* gd_layout-totals_only = 'X'.* gd_layout-f2code = 'DISP'. "Sets fcode for when double* "click(press f2)* gd_layout-zebra = 'X'.* gd_layout-group_change_edit = 'X'.* gd_layout-header_text = 'helllllo'.endform. " BUILD_LAYOUT

*&---------------------------------------------------------------------**& Form DISPLAY_ALV_REPORT*&---------------------------------------------------------------------** Display report using ALV grid*----------------------------------------------------------------------*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'* i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[]* it_special_groups = gd_tabgroup it_events = gt_events is_print = gd_prntparams i_save = 'X'* is_variant = z_template tables t_outtab = it_ekko 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 DATA_RETRIEVAL*&---------------------------------------------------------------------** Retrieve data form EKPO table and populate itab it_ekko*----------------------------------------------------------------------*form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh up to 10 rows from ekpo

into table it_ekko.endform. " DATA_RETRIEVAL

*-------------------------------------------------------------------** Form TOP-OF-PAGE **-------------------------------------------------------------------** ALV Report Header **-------------------------------------------------------------------*form top-of-page.*ALV Header declarationsdata: 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.

* Title wa_header-typ = 'H'.

wa_header-info = 'EKKO Table 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.

* Total No. of Records Selected describe table it_ekko lines ld_lines. ld_linesc = ld_lines. concatenate 'Total No. of Records Selected: ' ld_linesc into t_line separated by space. wa_header-typ = 'A'. wa_header-info = t_line. append wa_header to t_header. clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE' exporting it_list_commentary = t_header.* i_logo = 'Z_LOGO'.endform.

*------------------------------------------------------------------** FORM USER_COMMAND **------------------------------------------------------------------** --> R_UCOMM ** --> RS_SELFIELD **------------------------------------------------------------------*form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.

* Check function code case r_ucomm. when '&IC1'.* Check field clicked on within ALVgrid report if rs_selfield-fieldname = 'EBELN'.* Read data table, using index of row user clicked on read table it_ekko into wa_ekko index rs_selfield-tabindex.* Set parameter ID for transaction screen field set parameter id 'BES' field wa_ekko-ebeln.* Sxecute transaction ME23N, and skip initial data entry screen call transaction 'ME23N' and skip first screen.

endif. endcase.endform.

*&---------------------------------------------------------------------**& Form BUILD_EVENTS*&---------------------------------------------------------------------** Build events table*----------------------------------------------------------------------*form build_events. data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET' exporting i_list_type = 0 importing et_events = gt_events[]. read table gt_events with key name = slis_ev_end_of_page into ls_event. if sy-subrc = 0. move 'END_OF_PAGE' to ls_event-form. append ls_event to gt_events. endif.

read table gt_events with key name = slis_ev_end_of_list into ls_event. if sy-subrc = 0. move 'END_OF_LIST' to ls_event-form. append ls_event to gt_events. endif.endform. " BUILD_EVENTS

*&---------------------------------------------------------------------**& Form BUILD_PRINT_PARAMS*&---------------------------------------------------------------------** Setup print parameters*----------------------------------------------------------------------*form build_print_params. gd_prntparams-reserve_lines = '3'. "Lines reserved for footer gd_prntparams-no_coverpage = 'X'.endform. " BUILD_PRINT_PARAMS

*&---------------------------------------------------------------------**& Form END_OF_PAGE*&---------------------------------------------------------------------*form end_of_page. data: listwidth type i, ld_pagepos(10) type c, ld_page(10) type c.

write: sy-uline(50). skip. write:/40 'Page:', sy-pagno .endform.

*&---------------------------------------------------------------------**& Form END_OF_LIST*&---------------------------------------------------------------------*form end_of_list. data: listwidth type i, ld_pagepos(10) type c, ld_page(10) type c.

skip. write:/40 'Page:', sy-pagno .endform.

*&---------------------------------------------------------------------**& Report ZBAPI1_BRF*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zbapi1_brf.

*Crear ordenes de compra, la transacción para crear una orden de compra es la me21n*Lo primero es declarar nuestras tablas internas que mantendran los datos *correspondientes, haciendolo de esta manera:

data: l_poheader like bapimepoheader.data: l_poheaderx like bapimepoheaderx.data: l_t_poitem like bapimepoitem occurs 0 with header line.data: l_t_poitemx like bapimepoitemx occurs 0 with header line.data: l_t_poschedule like bapimeposchedule occurs 0 with header line.data: l_t_poschedulex like bapimeposchedulx occurs 0 with header line.data: l_t_return like bapiret2 occurs 0 with header line.

*Declaramos un espacio para nuestra orden de compra.data : v_purchaseorder like bapiekkoc-po_number.

*En mi caso puse un parametro para la selección de mi proveedor.selection-screen begin of block block01 with frame title text-001.skip 1.parameter: p_vendor like l_poheader-vendor obligatory.uline.skip 1.selection-screen end of block block01.

perform rellenar_bapi_cab using p_vendor.perform rellenar_bapi_pos.perform crear_pedido_compra.

*Y bien comenzamos, esta rutina me rellena la cabezera de mi orden, lo que vendria *siendo de la tabla ekko.form rellenar_bapi_cab using p_vendor.

clear l_poheader.clear l_poheaderx.

l_poheader-comp_code = '0200'. "sociedadl_poheader-doc_type = 'PGOC'. "Clase del documentol_poheader-creat_date = sy-datlo. "Fecha de creaciónl_poheader-created_by = sy-uname. "Responsable que añadió el objetol_poheader-vendor = p_vendor. "Proveedorl_poheader-purch_org = 'OC02'. "Organización de comprasl_poheader-pur_group = 'G03'. "Grupo de comprasl_poheader-doc_date = sy-datum. "Fecha del documento

l_poheaderx-comp_code = 'X'.l_poheaderx-doc_type = 'X'.l_poheaderx-creat_date = 'X'.l_poheaderx-created_by = 'X'.l_poheaderx-vendor = 'X'.l_poheaderx-purch_org = 'X'.l_poheaderx-pur_group = 'X'.l_poheaderx-doc_date = 'X'.

endform. " rellenar_bapi_cab

*Ahora la rutina para mi detalle que vendría siendo lo de la tabla ekpo.form rellenar_bapi_pos.

data: pos_rep like ekpo-ebelp.

clear pos_rep.

clear: l_t_poitem, l_t_poitemx, l_t_poschedule, l_t_poschedulex.add 10 to pos_rep.

l_t_poitem-po_item = pos_rep.l_t_poitem-material = '000000021033017002'.l_t_poitem-plant = 'B001'. "Centrol_t_poitem-stge_loc = 'B001'. "almacénl_t_poitem-quantity = '12'.l_t_poitem-po_unit = 'PAA'.l_t_poitem-item_cat = '2'.append l_t_poitem.

l_t_poitemx-po_item = pos_rep.l_t_poitemx-po_itemx = 'X'.l_t_poitemx-material = 'X'.l_t_poitemx-plant = 'X'.l_t_poitemx-stge_loc = 'X'.l_t_poitemx-quantity = 'X'.l_t_poitemx-po_unit = 'X'.l_t_poitemx-item_cat = 'X'.append l_t_poitemx.

l_t_poschedule-po_item = pos_rep.l_t_poschedule-delivery_date = sy-datum.l_t_poschedule-quantity = '12'.l_t_poschedule-deliv_time = sy-uzeit.append l_t_poschedule.

l_t_poschedulex-po_item = pos_rep.l_t_poschedulex-po_itemx = 'X'.l_t_poschedulex-delivery_date = 'X'.l_t_poschedulex-quantity = 'X'.l_t_poschedulex-deliv_time = 'X'.append l_t_poschedulex.

endform. " rellenar_bapi_pos

*Y por ultimo mandamos a llamar nuestra bapi con exportando nuestras tablas e *importando la orden que se creará =).form crear_pedido_compra .

call function 'BAPI_PO_CREATE1'exportingpoheader = l_poheaderpoheaderx = l_poheaderximportingexppurchaseorder = v_purchaseordertablesreturn = l_t_returnpoitem = l_t_poitempoitemx = l_t_poitemxposchedule = l_t_poscheduleposchedulex = l_t_poschedulex.

if not v_purchaseorder is initial.call function 'BAPI_TRANSACTION_COMMIT'exportingwait = 'X'* IMPORTING* RETURN =.write : / v_purchaseorder.loop at l_t_return.write: / l_t_return-message.endloop.else.call function 'BAPI_TRANSACTION_ROLLBACK'.*En caso de que halla error, me lo regrese.

loop at l_t_return.write: / l_t_return-message.endloop.

endif.

endform. " crear_pedido_compra

*&---------------------------------------------------------------------**& Report ZBATCH_BRF_XD02_A*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

*REPORT ZBATCH_BRF_XD02_A.

report zbatch_brf_xd02 no standard page heading line-size 255.

*include bdcrecx1.

*start-of-selection.

*perform open_group.

parameters: file type rlgrap-filename.

data: begin of bdc_tab occurs 0. include structure bdcdata.data: end of bdc_tab.

data: i_msg2 like bdcmsgcoll occurs 0 with header line, i_msg like bdcmsgcoll occurs 0 with header line, modo type c, update type c.

*Dejarlos en código duro o como parametros de selección modo = 'A'. update = 'L'.

refresh bdc_tab.

perform bdc_dynpro using 'SAPMF02D' '0101'. "'X'perform bdc_field using 'BDC_CURSOR' 'RF02D-KUNNR'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'RF02D-KUNNR' '3200000006'.perform bdc_dynpro using 'SAPMF02D' '0101'.perform bdc_field using 'BDC_CURSOR' 'RF02D-D0110'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'RF02D-KUNNR' '3200000006'.perform bdc_field using 'RF02D-D0110' 'X'.perform bdc_dynpro using 'SAPMF02D' '0110'.perform bdc_field using 'BDC_CURSOR' 'KNA1-NAME3'.perform bdc_field using 'BDC_OKCODE' '=UPDA'.perform bdc_field using 'KNA1-NAME1' 'Grupo Motor'.perform bdc_field using 'KNA1-SORTL' 'MOTOR'.perform bdc_field using 'KNA1-NAME2' 'Prueba para completar información'.perform bdc_field using 'KNA1-NAME3' 'de los clientes'.perform bdc_field using 'KNA1-STRAS' 'Gran Vía 2B'.perform bdc_field using 'KNA1-ORT01' 'Madrid'.perform bdc_field using 'KNA1-PSTLZ' '23004'.perform bdc_field using 'KNA1-LAND1' 'ES'.perform bdc_field using 'KNA1-SPRAS' 'ES'.

*perform bdc_transaction using 'XD02'.

call transaction 'XD02' using bdc_tab mode modo update update messages into i_msg2. " AND SKIP FIRST SCREEN*Controlar los mensajes*APPEND LINES OF i_msg2 to i_msg.* READ TABLE i_msg2 INTO wa_mesg WITH KEY msgtyp = 'E' msgid = 'V1' msgnr = '042'.

wait up to 1 seconds.**&---------------------------------------------------------------------**& Form BDC_DYNPRO*&---------------------------------------------------------------------** text: Start a new screen*----------------------------------------------------------------------** program* dynpro*----------------------------------------------------------------------*form bdc_dynpro using program dynpro.clear bdc_tab. bdc_tab-program = program. bdc_tab-dynpro = dynpro. bdc_tab-dynbegin = 'X'. append bdc_tab.endform. " BDC_DYNPRO*&---------------------------------------------------------------------**& Form BDC_FIELD*&---------------------------------------------------------------------** text Inserts a field*----------------------------------------------------------------------** fnam* fval*----------------------------------------------------------------------*form bdc_field using fnam fval.clear bdc_tab. bdc_tab-fnam = fnam. bdc_tab-fval = fval. append bdc_tab.

endform. " BDC_FIELD

report zbatch_brf_xd02_b no standard page heading line-size 255.

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'SAPMF02D' '0101'.perform bdc_field using 'BDC_CURSOR' 'RF02D-D0110'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'RF02D-KUNNR' '3200000006'.perform bdc_field using 'RF02D-D0110' 'X'.perform bdc_dynpro using 'SAPMF02D' '0110'.perform bdc_field using 'BDC_CURSOR' 'KNA1-ORT02'.perform bdc_field using 'BDC_OKCODE' '=UPDA'.perform bdc_field using 'KNA1-NAME1' 'Grupo Motor'.perform bdc_field using 'KNA1-SORTL'

'MOTOR'.perform bdc_field using 'KNA1-NAME2' 'Prueba para completar información'.perform bdc_field using 'KNA1-NAME3' 'de los clientes'.perform bdc_field using 'KNA1-STRAS' 'Gran Vía 2B'.perform bdc_field using 'KNA1-ORT01' 'Madrid'.perform bdc_field using 'KNA1-PSTLZ' '23004'.perform bdc_field using 'KNA1-ORT02' 'España'.perform bdc_field using 'KNA1-LAND1' 'ES'.perform bdc_field using 'KNA1-SPRAS' 'ES'.perform bdc_field using 'KNA1-TELF1' '1233445'.perform bdc_transaction using 'XD02'.

perform close_group.

*&---------------------------------------------------------------------**& Report ZBDL_BRF*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zbdl_brf.

tables: mkpf, mseg.

data: it_mkpf type standard table of mkpf with header line, wa_mkpf type mkpf.

start-of-selection.

*GET 1get mkpf.

check mkpf-mblnr+0(2) = '49' .

wa_mkpf = mkpf.

*write wa_mkpf-mblnr.

append wa_mkpf to it_mkpf.* delete adjacent duplicates it_mkpf byloop at it_mkpf into wa_mkpf.write: /5 wa_mkpf-mblnr.

endloop.

*GET 2get mseg.

*&---------------------------------------------------------------------**& Report ZBRF*&*&---------------------------------------------------------------------**&

*&*&---------------------------------------------------------------------*

report zbrf.

*data: begin of it_clientes occurs 0,* codigo(2) type N,* alumno(15) type C,* end of it_clientes.**START-OF-SELECTION.* it_clientes-codigo = 01.* it_clientes-alumno = 'pepe'.* append it_clientes.*** write:/'codigo:',it_clientes-codigo.* write:/'alumno:',it_clientes-alumno.* write:/.* write:sy-uline(50).* it_clientes-codigo = 01.* it_clientes-alumno = 'pepe'.* append it_clientes.* it_clientes-codigo = 02.* it_clientes-alumno = 'pati'.* append it_clientes.* it_clientes-codigo = 03.* it_clientes-alumno = 'jaco'.* append it_clientes.** loop at it_clientes.* write:/'codigo:',it_clientes-codigo.* write:/'alumno:',it_clientes-alumno.* endloop.*

****************************************************++*tables: dfkkko. ", dfkkop, but020, adrc.*** data: tabla type standard table of dfkkko with header line.***Campos de trasferencia para la tabla DFKKKO***** tabla-opbel = '280000217376'.* tabla-fikey = 'X20051031002'.* tabla-applk = 'P'.* tabla-blart = 'AP'.* tabla-herkf = '01'.* tabla-ernam = 'USUARIO1'.* tabla-cpudt = '20060322'.* tabla-cputm = '004408'.* tabla-waers = 'MXN'.* tabla-bldat = '20051031'.* tabla-budat = '20051031'.* tabla-wwert = '20051031'.* tabla-xblnr = 'EP000000520'.* tabla-awtyp = 'FKKKO'.* tabla-awkey = '280000217376'.* tabla-storb = ''.** move-corresponding tabla to dfkkko.* insert dfkkko.*****delete dfkkko.** if sy-subrc eq 0.* write: 'bien!!!!'.* else.* write: 'lo sentimos no fue posible la transferencia'.* endif.

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

*REPORT NO STANDARD PAGE HEADING LINE-SIZE 121 LINE-COUNT (5) MESSAGE-ID zcurso02.**TABLES: spfli, "carrid AAA, BBB, CCC* sflight, "conid 1111, 2222, 3333* scarr.**SELECT-OPTIONS: s_carrid FOR sflight-carrid,* s_connid FOR sflight-connid,* s_cdfrom FOR spfli-cityfrom,* s_cdto FOR spfli-cityto.****DATA: BEGIN OF it_hdr OCCURS 0,* carrid TYPE sflight-carrid,* carrname TYPE scarr-carrname,* connid TYPE sflight-connid,* cityfrom TYPE spfli-cityfrom,* airpfrom TYPE spfli-airpfrom,* cityto TYPE spfli-cityto,* airpto TYPE spfli-airpto,* END OF it_hdr.**DATA: BEGIN OF it_dtl OCCURS 0,* fldate TYPE sflight-fldate,* seatsmax TYPE sflight-seatsmax,* connid TYPE sflight-connid,* seatsocc TYPE sflight-seatsocc,* price TYPE sflight-price,* prec_tot TYPE p DECIMALS 2,* por_seats TYPE p DECIMALS 2,* END OF it_dtl.***DATA: wa_hdr LIKE it_hdr,* wa_dtl LIKE it_dtl.***START-OF-SELECTION.*** SELECT DISTINCT b~carrid b~carrname a~connid* c~cityfrom c~airpfrom c~cityto c~airpto* INTO TABLE it_hdr** FROM sflight AS a* INNER JOIN scarr AS b* ON a~carrid = b~carrid* INNER JOIN spfli AS c* ON c~carrid = b~carrid* AND a~connid = c~connid* WHERE a~carrid IN s_carrid* AND a~connid IN s_connid* AND c~cityfrom IN s_cdfrom* AND c~cityto IN s_cdto.** SORT it_hdr DESCENDING BY carrid.*** FORMAT COLOR 4.** IF sy-subrc EQ 0.* MESSAGE i003.** LOOP AT it_hdr INTO wa_hdr.* WRITE:/ '|',wa_hdr-carrid,' |', "2 espacios

* wa_hdr-carrname,'|', "0 espacios* wa_hdr-connid,' |', "4 espacios* wa_hdr-cityfrom,'|', "0 espacios* wa_hdr-airpfrom,' |', "5 espacios* wa_hdr-cityto,'|', "0 espacios* wa_hdr-airpto,' |'. "2 espacios** HIDE: wa_hdr-carrname,* wa_hdr-connid,* wa_hdr-connid.** ULINE AT (108).* ENDLOOP.** ELSE.* MESSAGE i004.* ENDIF.***AT LINE-SELECTION.* IF sy-lsind = 1 and sy-curow > 3.* SELECT fldate seatsmax connid seatsocc price* FROM sflight* INTO TABLE it_dtl* WHERE connid = wa_hdr-connid.*** LOOP AT it_dtl INTO wa_dtl.** wa_dtl-por_seats = wa_dtl-seatsocc * 100 / wa_dtl-seatsmax.** wa_dtl-prec_tot = wa_dtl-price * wa_dtl-seatsocc.* FORMAT COLOR 2.* WRITE:/ '|',wa_dtl-fldate,' |',* wa_dtl-seatsmax,'|',* wa_dtl-seatsocc,'|',* wa_dtl-prec_tot,'|',* wa_dtl-por_seats,'|'.** ULINE AT (82).* ENDLOOP.** ENDIF.**TOP-OF-PAGE.* ULINE.* FORMAT COLOR 3.* WRITE: '|',5 'Id ','|',* 17 'Nombre',' |', "8 espacios* 34 '#Vuelo ',' |', "1 espacio* 53 'CdFrom',' |', "6 espacios* 70 'AiFrom','|', "0 espacios* 87 'CdTo',' |', "8 espacios* 103'AiTo','|'. "0 espacios** ULINE at (108).**TOP-OF-PAGE DURING LINE-SELECTION.* FORMAT COLOR 1.* ULINE AT (82).* WRITE:/ '| ', text-001, "24 espacios* ' |'. "36 espacios* WRITE:/* '|' , (11) 'Aerolínea:', wa_hdr-carrname,* (40) ' No.vuelo:', "29 espacios*wa_hdr-connid, '|'. "33 espacios*** ULINE .* FORMAT COLOR 4 .

* WRITE: '| ',6 'fecha',' |', "2/4 espacios* 19 'Max.Asi',' |', "2 espacios* 32 'Asi.Occ',' |', "2 espacios* 51 'Totales',' |', "3 espacios* 68 'Porcentaje',' |'. "3 espacios** ULINE at (82).************************************************REPORT zprogrambrf01 LINE-SIZE 80.*****KNA1= nombre de la tabla****PARAMETERS p_kunnr TYPE kna1-kunnr OBLIGATORY.****DATA wa_kna1 TYPE kna1.*******definir tabla interna que tenga la misma definicion que la scarr**DATA it_kna1 TYPE STANDARD TABLE OF kna1.****SELECT carrid carrname currcode url**FROM scarr**INTO CORRESPONDING FIELDS OF TABLE it_scarr.****IF sy-subrc NE 0.** WRITE :/ 'No se encontraron datos.'.**ENDIF.****LOOP AT it_scarr INTO wa_scarr.** WRITE : /2 wa_scarr-carrid,** 12 wa_scarr-carrname,** 35 wa_scarr-currcode,** 50 wa_scarr-url(30).**ENDLOOP.

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

tables: bkpf, bseg. ", dfkkop, but020, adrc.

data: tabla type standard table of bkpf with header line. data: tabla type standard table of bseg with header line.data: wa_bkpf type bkpf, wa_bseg type bseg.

*OPCION 1types: begin of t_bkpf_bseg.include structure bkpf.*include structure bseg.types: bukrs type bseg-bukrs, "ya existe en BKPF belnr type bseg-belnr, "ya existe en BKPF gjahr type bseg-gjahr, "ya existe en BKPF

buzei type bseg-buzei.types: end of t_bkpf_bseg.

data: it_bkpf_bseg type standard table of t_bkpf_bseg initial size 0, wa_bkpf_bseg type t_bkpf_bseg.

*OPCION 2*data: begin of it_bkpf_bseg,* bukrs type bkpf/bseg-bukrs,* belnr type bkpf/bseg-belnr,* gjahr type bkpf/bseg-gjahr,* buzei type bseg-buzei,* ....* .* .data: wa_bkpf_bseg type t_bkpf_bseg.

select * into table it_bkpf from bkpf.

select * into table it_bseg for all entries in it_bkpf from bseg where bukrs = it_bkpf-bukrs and belnr = it_bkpf-belnr and gjahr = it_bkpf-gjahr.

loop at it_bkpf into wa_bkpf.

*OPCION 1 loop at it_bseg into wa_bseg where bukrs = wa_bkpf-bukrs and belnr = wa_bkpf-belnr and gjahr = wa_bkpf-gjahr.*OPCION 2* read table it_bseg into wa_bseg with key bukrs = wa_bkpf-bukrs* belnr = wa_bkpf-belnr* gjahr = wa_bkpf-gjahr.

***read table it_bseg index 5.if sy-subrc = 0.

wa_bkpf_bseg-bukrs = wa_bkpf-bukrs. "wa_bseg-bukrs.wa_bkpf_bseg-belnr = wa_bkpf-belnr. "wa_bseg-belnr.wa_bkpf_bseg-gjahr = wa_bkpf-gjahr. "wa_bseg-gjahr.wa_bkpf_bseg-buzei = wa_bseg-buzei.

append it_bkpf_bseg from wa_bkpf_bseg.endif.*endloop.endloop.

delete scarr from table tabla.* if sy-subrc eq 0. write: 'bien!!!!'. else. write: 'lo sentimos no fue posible la transferencia'. endif.

*&---------------------------------------------------------------------**& Report ZBRF_2*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

*REPORT ZBRF_2.

**Create Push Buttons in Application Tool Bar**How to create pushbuttons in application tool bar in case of selection-screen?**REPORT zsiva_test*MESSAGE-ID zprecot.*TABLES : afru.**TYPES : BEGIN OF ty_test,* ism01 LIKE afru-ism01,* END OF ty_test.*TABLES sscrfields.**SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.*SELECT-OPTIONS : so_werks FOR afru-werks.*SELECTION-SCREEN PUSHBUTTON /79(10) charly USER-COMMAND abcd.*SELECTION-SCREEN END OF BLOCK b1.**INITIALIZATION.* MOVE 'Press' TO charly.**START-OF-SELECTION.**END-OF-SELECTION.***AT SELECTION-SCREEN.* IF sscrfields-ucomm = 'ABCD'.* MESSAGE i000 WITH so_werks-low 'Success' .* ENDIF.**

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

*Example Code For Drill Down Reportreport zmm_rept_purchorderkkb01 line-size 80 line-count 65(3) message-id z_msg_class no standard page heading.

*------------------DECLARING THE STANDARD TABLES---------------------*tables : ekko, "PURCHASE ORDER : HEADER ekpo. "PURCHASE ORDER : ITEM

*------------------DECLARING THE INTERNAL TABLE----------------------*data : begin of it_ekko occurs 2, ebeln like ekko-ebeln, "PURCHASE ORDER NUMBER bukrs like ekko-bukrs, "COMPANY CODE bsart like ekko-bsart, "PURCHASING DOCUMENT TYPE lifnr like ekko-lifnr, "VENDOR spras like ekko-spras, "LANGUAGE KEY zterm like ekko-zterm, "PAYMENT TERMS KEY end of it_ekko.

data : begin of it_ekpo occurs 2,

ebeln like ekpo-ebeln, "PURCHASE ORDER NUMBER ebelp like ekpo-ebelp, "PURCHASE ORDER NUMBER werks like ekpo-werks, "PLANT matnr like ekpo-matnr, "MATERIAL NUMBER matkl like ekpo-matkl, "MATERIAL GROUP end of it_ekpo.

data: it_ebeln like ekko-ebeln occurs 0 with header line.

*DATA: it_ebeln_high LIKE ekko-ebeln OCCURS 0 WITH HEADER LINE.

data: p_ebeln type i.

*------------------Declaring the selection screen--------------------*

selection-screen begin of block blk1 with frame title text-001.

select-options : s_ebeln for ekko-ebeln.

parameter : p_limit type i.

selection-screen end of block blk1.

*INCLUDE z_incl_purorderkkb01_sub_f01.

*--------------------------------------------------------------------** Validation for number of records to be printed **--------------------------------------------------------------------*

*AT SELECTION-SCREEN ON p_limit.* IF p_limit IS INITIAL.* MESSAGE e011.* ENDIF.

* IF p_limit GT sy-linct.* MESSAGE e010.* ENDIF.

*----------------------------------------------------------------------** Search help for purchase document number (s_ebeln-low) **----------------------------------------------------------------------*

at selection-screen on value-request for s_ebeln-low. call function 'CONVERSION_EXIT_ALPHA_INPUT' exporting input = s_ebeln-low importing output = s_ebeln-low.

perform form_search_help.

if sy-subrc <> 0. case sy-subrc. when 2. leave to screen 1000. endcase. else. loop at it_ebeln. if sy-tabix = p_ebeln. s_ebeln-low = it_ebeln. exit. endif. endloop. endif.

*----------------------------------------------------------------------*

* Search help for purchase document number (s_ebeln-high) **----------------------------------------------------------------------*

at selection-screen on value-request for s_ebeln-high. call function 'CONVERSION_EXIT_ALPHA_INPUT' exporting input = s_ebeln-high importing output = s_ebeln-high.

perform form_search_help.

if sy-subrc <> 0. case sy-subrc. when 2. leave to screen 1000. endcase. else. loop at it_ebeln. if sy-tabix = p_ebeln. s_ebeln-high = it_ebeln. exit. endif. endloop. endif.

*----------------------------------------------------------------------** Start-of-selection event **----------------------------------------------------------------------*

start-of-selection.

*----------------------To attach a user interface----------------------*set pf-status '0010'.

*---------To fetch the data for the basic list-------------------------* select ebeln "PURCHASE ORDER NUMBER bukrs "COMPANY CODE bsart "PURCHASING DOCUMENT TYPE lifnr "VENDOR spras "LANGUAGE KEY zterm "PAYMENT TERMS KEY up to p_limit rows into table it_ekko from ekko where ebeln in s_ebeln.

refresh it_ekpo.

*---------To fetch the data for the secondary list-----------------------*

if it_ekpo is initial.

select ebeln "PURCHASE ORDER NUMBER ebelp "PURCHASING DOCUMENT TYPE werks "PLANT matnr "MATERIAL NUMBER matkl "MATERIAL GROUP from ekpo into table it_ekpo for all entries in it_ekko where ebeln eq it_ekko-ebeln.

endif.

*----------------------------------------------------------------------** End-of-selection event **----------------------------------------------------------------------*

end-of-selection.

*---------To display the data for the basic list-----------------------*

format color 4 intensified off. loop at it_ekko. write :/ sy-vline, it_ekko-ebeln under text-002, 18 sy-vline, "PURCHASE ORDER NUMBER it_ekko-bukrs under text-003, 27 sy-vline, "COMPANY CODE it_ekko-bsart under text-004, 38 sy-vline, "PURCHASING DOCUMENT TYPE it_ekko-lifnr under text-005, 50 sy-vline, "VENDOR it_ekko-spras under text-006, 62 sy-vline, "LANGUAGE KEY it_ekko-zterm under text-007, 80 sy-vline. "PAYMENT TERMS KEY

hide : it_ekko-ebeln. endloop. write :/ sy-uline(80).

*----------------------------------------------------------------------** To generate the detailed lists **----------------------------------------------------------------------*

at line-selection. case sy-lsind. when 1. set pf-status '0011'.

*---------To display the data for the secondary list-----------------------*window starting at 10 10 ending at 90 30. format color 5 intensified off. loop at it_ekpo where ebeln = it_ekko-ebeln . write :/ sy-vline, it_ekpo-ebeln under text-002, 15 sy-vline, "PURCHASE ORDER NUMBER it_ekpo-ebelp under text-008, 30 sy-vline, "PO ITEM NUMBER it_ekpo-werks under text-009, 45 sy-vline, "PLANT it_ekpo-matnr under text-010, 60 sy-vline, "MATERIAL NUMBER it_ekpo-matkl under text-011, 80 sy-vline. "MATERIAL GROUP endloop.

write :/ sy-uline(80).

endcase.

case sy-ucomm. when 'EXIT' or 'CANC' or 'BACK'. leave to screen 0. endcase.

*----------------------------------------------------------------------** At user-command event **----------------------------------------------------------------------*

at user-command. case sy-ucomm. when 'SELE' or 'LIST1'. if sy-lsind = 1. set pf-status '0011'.

*---------To display the data for the secondary list-----------------------*

window starting at 10 10 ending at 90 30. format color 5 intensified off.

loop at it_ekpo where ebeln = it_ekko-ebeln . write :/ sy-vline, it_ekpo-ebeln under text-002, 15 sy-vline, "PURCHASE ORDER NUMBER it_ekpo-ebelp under text-008, 30 sy-vline, "PO ITEM NUMBER it_ekpo-werks under text-009, 45 sy-vline, "PLANT it_ekpo-matnr under text-010, 60 sy-vline, "MATERIAL NUMBER it_ekpo-matkl under text-011, 80 sy-vline. "MATERIAL GROUP

endloop.

write :/ sy-uline(80). endif.

endcase.

case sy-ucomm. when 'EXIT' or 'CANC' or 'BACK'. leave to screen 0.

endcase.

*----------------------------------------------------------------------** Top-of-page for basic list **----------------------------------------------------------------------*

top-of-page.

format color 3 intensified off.

write :/ sy-uline(80). write :/ sy-vline, 03 sy-repid, 60 text-015, sy-uname, 80 sy-vline. write :/ sy-vline, 03 sy-datum, 35 text-012, 60 text-014, sy-pagno, 80 sy-vline. write :/ sy-uline(80). write :/ sy-vline, text-002, 18 sy-vline, "PURCHASE ORDER NUMBER text-003, 27 sy-vline, "COMPANY CODE text-004, 38 sy-vline, "PURCHASING DOCUMENT TYPE text-005, 50 sy-vline, "VENDOR text-006, 62 sy-vline, "LANGUAGE KEY text-007, 80 sy-vline. "PAYMENT TERMS KEY write :/ sy-uline(80).

*----------------------------------------------------------------------** Top-of-page for secondary list **----------------------------------------------------------------------*

top-of-page during line-selection.format color 2 intensified off.window starting at 10 10 ending at 90 30. write :/ sy-uline(80). write :/ sy-vline, 03 sy-repid, 60 text-015, sy-uname, 80 sy-vline.

write :/ sy-vline, 03 sy-datum, 35 text-013, 60 text-014, sy-pagno, 80 sy-vline.

write :/ sy-uline(80).

write :/ sy-vline, text-014, 15 sy-vline, "PURCHASE ORDER NUMBER text-008, 30 sy-vline, "PO ITEM NUMBER text-009, 45 sy-vline, "PLANT text-010, 60 sy-vline, "MATERIAL NUMBER text-011, 80 sy-vline. "MATERIAL GROUP

write :/ sy-uline(80).

*----------------------------------------------------------------------** End-of-page event **----------------------------------------------------------------------*

end-of-page. write :/ sy-vline, 03 text-016, p_limit, 60 text-014, sy-pagno, 80 sy-vline. write:/ sy-uline(80).

*INCLUDE Z_INCLUDE_PURCHORDERKKB01.form form_search_help .

refresh it_ebeln. clear it_ebeln. clear p_ebeln.

select ebeln from ekko into table it_ebeln.

call function 'POPUP_WITH_TABLE_DISPLAY' exporting endpos_col = 21 endpos_row = 35 startpos_col = 12 startpos_row = 1 titletext = text-012

importing choise = p_ebeln

tables valuetab = it_ebeln

exceptions break_off = 1 others = 2.

endform.**************************************************************************************************************************************+*******************************************************************

** A demo program to create subscreen in your ABAP Program**** A demo program to create subscreen in your ABAP Program**** This report will display the user last login date and time.**** Subscreen selection 1 : User Name** 2 : Last Login Date** 3 : Class Belong To**** Written by : SAP Basis, ABAP Programming and Other IMG Stuff** http://www.sap-img.com***

*REPORT ZSUBSCREEN.**TABLES: USR02, "Logon data* SSCRFIELDS. "FIELDS ON SELECTION SCREENS**---------------------------------------------------------------** SUBSCREEN 1**---------------------------------------------------------------*SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.*SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.* SELECT-OPTIONS: USERNAME FOR USR02-BNAME.*SELECTION-SCREEN END OF BLOCK B1.*SELECTION-SCREEN END OF SCREEN 100.***---------------------------------------------------------------** SUBSCREEN 2**---------------------------------------------------------------*SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.*SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.* SELECT-OPTIONS: LASTLOGI FOR USR02-TRDAT.*SELECTION-SCREEN END OF BLOCK B2.*SELECTION-SCREEN END OF SCREEN 200.***---------------------------------------------------------------** SUBSCREEN 3**---------------------------------------------------------------*SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.*SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.* SELECT-OPTIONS: CLASSTYP FOR USR02-CLASS.*SELECTION-SCREEN END OF BLOCK B3.*SELECTION-SCREEN END OF SCREEN 300.*** STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT*SELECTION-SCREEN: FUNCTION KEY 1,* FUNCTION KEY 2.**SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,* END OF BLOCK SUB.**START-OF-SELECTION.* SELECT * FROM USR02 WHERE BNAME IN USERNAME* AND ERDAT IN LASTLOGI* AND CLASS IN CLASSTYP.* WRITE: / 'User ', USR02-BNAME,* 'Last Login Date ', USR02-TRDAT,* 'Last Login Time ', USR02-LTIME,* 'CLASS ', USR02-CLASS.* ENDSELECT.*END-OF-SELECTION.**INITIALIZATION.** SCREEN ICON LEFT AND RIGHT* SSCRFIELDS-FUNCTXT_01 = '@0D@'.* SSCRFIELDS-FUNCTXT_02 = '@0E@'.* SUB-PROG = SY-REPID.* SUB-DYNNR = 100.**AT SELECTION-SCREEN.* CASE SY-DYNNR.** WHEN 100.* IF SSCRFIELDS-UCOMM = 'FC01'.* SUB-DYNNR = 300.* ELSEIF SSCRFIELDS-UCOMM = 'FC02'.* SUB-DYNNR = 200.* ENDIF.** WHEN 200.* IF SSCRFIELDS-UCOMM = 'FC01'.* SUB-DYNNR = 100.* ELSEIF SSCRFIELDS-UCOMM = 'FC02'.

* SUB-DYNNR = 300.* ENDIF.** WHEN 300.* IF SSCRFIELDS-UCOMM = 'FC01'.* SUB-DYNNR = 200.* ELSEIF SSCRFIELDS-UCOMM = 'FC02'.* SUB-DYNNR = 100.* ENDIF.* ENDCASE.

**&---------------------------------------------------------------------***& Report ZBRF_POO**&**&---------------------------------------------------------------------***&**&**&---------------------------------------------------------------------**report zbrf_poo.**Es el mismo reporte solo qye este codigo comentado manda error de*STATEMENT IS NOT ACCESSIBLE**DATA customer_count TYPE i.*DATA tyre_price TYPE f.*DATA var1 TYPE i VALUE 786.*var1 = 890.*MOVE 900 TO var1.*WRITE 'ABAP/4 is easy.'.*WRITE / var1.***& try text field literal vs string literal**DATA: str1(10) TYPE c VALUE 'abc',* str2(10) TYPE c VALUE 'abc '.**IF str1 = str2.* WRITE / 'str1 and str2 are same'.*ELSE.* WRITE / 'str1 and str2 are not same'.*ENDIF.**DATA: str3 TYPE string VALUE `abc`,* str4 TYPE string VALUE `abc `.**IF str3 = str4.* WRITE / 'str3 and str4 are same'.*ELSE.* WRITE / 'str3 and str4 are not same'.*ENDIF.***CONSTANTS**CONSTANTS: c_nump TYPE p DECIMALS 3 VALUE '123.657',*c_city TYPE c LENGTH 10 VALUE 'manchester'.**c_nump = 23. causes syntax error***text symbols*WRITE / 'testign text symbols'.*WRITE: / text-001, / text-002, / text-0a0.******why is this not working??????**write 'can i store during run time' (002).**DO 5 TIMES.* PERFORM dataobject_example.* WRITE: / 'sy-index: ', sy-index.*ENDDO.*

**&--------------------------------------------------------------------***& Form dataobject_example**&--------------------------------------------------------------------*** text**---------------------------------------------------------------------**FORM dataobject_example.* DATA ct1 TYPE i.* STATICS ct2 TYPE i.* ct1 = ct1 + 1.* ct2 = ct2 + 1.* WRITE: / 'ct1: ', ct1, 'ct2: ', ct2.*ENDFORM. "dataobject_example**---------------------------------------------------------------------*** CLASS C1 DEFINITION**---------------------------------------------------------------------*****---------------------------------------------------------------------**CLASS c1 DEFINITION.* PUBLIC SECTION.* CLASS-DATA create_count TYPE i.* METHODS constructor.*ENDCLASS. "C1 DEFINITION**DATA: o1 TYPE REF TO c1,* o2 LIKE o1,* o3 LIKE o1.**CREATE OBJECT: o1,* o2,* o3.**WRITE: 'Number of created objects:', c1=>create_count.***---------------------------------------------------------------------*** CLASS C1 IMPLEMENTATION**---------------------------------------------------------------------*****---------------------------------------------------------------------**CLASS c1 IMPLEMENTATION.* METHOD constructor.* create_count = create_count + 1.* ENDMETHOD. "CONSTRUCTOR*ENDCLASS. "C1 IMPLEMENTATION

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

*Este codigo corrige el error STATEMENT IS NOT ACCESSIBLE del codigo* de arriba

data customer_count type i.data tyre_price type f.data var1 type i value 786.var1 = 890.move 900 to var1.write 'ABAP/4 is easy.'.write / var1.

*& try text field literal vs string literal

data: str1(10) type c value 'abc', str2(10) type c value 'abc '.

if str1 = str2. write / 'str1 and str2 are same'.else. write / 'str1 and str2 are not same'.endif.

*DATA: str3 TYPE string VALUE `abc`,* str4 TYPE string VALUE `abc `.*----->start of correctiondata: str3 type string, str4 type string.str3 = 'abc'.str4 = 'abc '.*<-----end of correction

if str3 = str4. write / 'str3 and str4 are same'.else. write / 'str3 and str4 are not same'.endif.

*CONSTANTS

*CONSTANTS: c_nump TYPE p DECIMALS 3 VALUE '123.657',*c_city TYPE c length 10 VALUE 'manchester'.*----->start of correctionconstants: c_nump type p decimals 3 value '123.657', c_city(10) type c value 'manchester'.*<-----end of correction*c_nump = 23. causes syntax error

*text symbolswrite / 'testign text symbols'.write: / text-001, / text-002, / text-0a0.*****why is this not working??????*write 'can i store during run time' (002).

perform create_object.

do 5 times. perform dataobject_example. write: / 'sy-index: ', sy-index.enddo.

*&--------------------------------------------------------------------**& Form dataobject_example*&--------------------------------------------------------------------** text*---------------------------------------------------------------------*form dataobject_example. data ct1 type i. statics ct2 type i. ct1 = ct1 + 1. ct2 = ct2 + 1. write: / 'ct1: ', ct1, 'ct2: ', ct2.endform. "dataobject_example*---------------------------------------------------------------------** CLASS C1 DEFINITION*---------------------------------------------------------------------***---------------------------------------------------------------------*class c1 definition. public section. class-data create_count type i. methods constructor.endclass. "C1 DEFINITION

*---------------------------------------------------------------------** CLASS C1 IMPLEMENTATION*---------------------------------------------------------------------***---------------------------------------------------------------------*class c1 implementation. method constructor. create_count = create_count + 1.

endmethod. "CONSTRUCTORendclass. "C1 IMPLEMENTATION*&---------------------------------------------------------------------**& Form create_object*&---------------------------------------------------------------------*form create_object. data: o1 type ref to c1, o2 like o1, o3 like o1.

create object: o1, o2, o3.

write: 'Number of created objects:', c1=>create_count.

endform. " create_object

*&---------------------------------------------------------------------**& Report ZBRF_POO_2*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zbrf_poo_2.

*----------------------------------------------------------------------** CLASS RAJ DEFINITION*----------------------------------------------------------------------***----------------------------------------------------------------------*class raj definition. public section. data: c type i. methods : sum importing a type i b type i exporting c type i.endclass. "RAJ DEFINITION

*----------------------------------------------------------------------** CLASS RAJ IMPLEMENTATION*----------------------------------------------------------------------***----------------------------------------------------------------------*class raj implementation. method sum. c = a + b. endmethod. "SUMendclass. "RAJ IMPLEMENTATION

data: v1 type i,v2 type i,sum type i.

data: obj type ref to raj.

start-of-selection.

create object obj. v1 = 2. v2 = 5.

call method obj->sum exporting a = v1 b = v2 importing c = sum.

write: sum.

*&---------------------------------------------------------------------**& Report ZBRF_RFC*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zbrf_rfc.

* Global Data Declarationtables: spfli.

parameters: p_carrid like spfli-carrid default '222', p_connid like spfli-connid default '1234', dest like rfcdes-rfcdest default 'NONE'. "Agregar para sincrona

data: system like sy-sysid.

data: itab_spfli type table of spfli, "agregar para asincrona msg_text(80), flag, return like sy-subrc.

* Calling the Functioncall function 'ZFM_RFC_BRF'destination dest "Agregar para sincrona

*The system starts a new session for the RFC and processes the results*directly after the RFC server answered. starting new task 'TASK1' "agregar para asincrona performing form_results on end of task "agregar para asincrona* exporting carrid = p_carrid connid = p_connid*Since you now receive the query results in a subroutine* IMPORTING "comentar para el caso de asincona* EX_SPFLI = spfli "comentar para el caso de asincona* SYSID = system "comentar para el caso de asincona exceptions* DATO_INVALIDO = 1 ""comentar para el caso de asincona communication_failure = 2 "agregar para sincrona system_failure = 3 "agregar para sincrona 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.

* Handling Exceptionscase sy-subrc. when 1. write 'No hay información disponible'. exit.

when 2. "agregar para sincrona write 'Conexión no pudo ser establecida'.

exit. when 3. "agregar para sincrona write 'Systema no disponible'. exit.

endcase.

* Wait Statement (Specify Condition) "agregar para asincrona*Include a wait loop to ensure that the data is displayed only after it was returned:wait until flag = 'X'. "agregar para asincrona*Add an if-else statement to the wait loop that checks whether the system did receive the data correctly and can display it:if return <> 0. "agregar para asincrona write: 'Error'. "agregar para asincronaelse. "agregar para asincrona

* Displaying Results

write: 'System:', system color 4. "agregar para sincronaskip 2.

write: spfli-carrid, spfli-connid, spfli-cityfrom, spfli-cityto, spfli-deptime, spfli-arrtime.

endif. "agregar para asincrona

* Set Context. Formal Parameters for Passing the Task Name.*subroutine that receives the data.*Include here the import parameters and the exception you deleted from the function call.form form_results using task.* Receiving Results of aRFC receive results from function 'ZFM_RFC_BRF' importing ex_spfli = spfli sys = system exceptions dato_invalido = 1.

*Finally, write the statements for processing the wait condition:* Processing Wait Condition return = sy-subrc. flag = 'X'.* Goto Wait Statementendform.

*&---------------------------------------------------------------------**& Report ZBRF_TRFC*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zbrf_trfc.

*Dentro de la selección se pide el customer number, el nuevo phone number, y el remote destination.*Relay the start time for the change by 5 minutes.

*The system changes the data in the local system and displays the change. In addition, it displays the*name of the remote system and the time at which the change will be executed in that system.

report xx_trfc_tutorial.* demo program for performing a transactional RFC

parameters: custid like scustom-id, phone like scustom-telephone, dest like rfcdes-rfcdest default 'NONE', time like sy-uzeit default sy-uzeit.

tables: scustom.data: customeritab like scustom occurs 0 with header line.

perform read_customeritab.*call in the same systemcall function 'XX_TRFC_CHANGE_SCUSTOM' exporting customer_id = custid i_telephone = phone exceptions no_data_found = 1.

if sy-subrc <> 0. write: 'Table entry could not be changed! ID:', custid.else. write: / 'Change executed in local system:'.endif.

perform read_customeritab.

*call for the other system with destination destcall function 'XX_TRFC_CHANGE_SCUSTOM' in background task destination dest exporting customer_id = custid i_telephone = phone.

* Plan job to start at given timecall function 'START_OF_BACKGROUNDTASK' exporting startdate = sy-datum starttime = time exceptions others = 1.if sy-subrc = 1. exit.endif.

* End of LUWcommit work.skip 1.write: / 'Remote System:', dest color 4 inverse.write: / 'Change in remote system planned via tRFC ==> Start time:', time.skip 2.write: / 'Double-click on OK to continue!.',40 'OK' color 5intensified.at line-selection. call transaction 'SM58'.

*Subroutine read_customeritabform read_customeritab. skip. select * from scustom into corresponding fields of table customeritab where id = custid. loop at customeritab. write: / 'ID: ', customeritab-id,

'Name: ', customeritab-name, 'Tel.: ', customeritab-telephone. endloop. uline.endform.

*&---------------------------------------------------------------------**& Report ZDEMO1*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

*REPORT ZDEMO1.

report zbdc3_va01 no standard page heading line-size 255. include bdcrecx1.

types : begin of ty_head, auart(4), vkorg(4), vtweg(2), spart(2), kunnr(10), bstkd(10), end of ty_head.

types: begin of ty_item, matnr(18) type c, kwmeng(13) type c, end of ty_item.

data: it_head type table of ty_head. " Headerdata: wa_head like line of it_head.

data: it_item type table of ty_item. " Itemdata: wa_item like line of it_item.

data:v_kwmeng(30) type c, v_mabnr(30) type c.data: val(2) type n value 01.data : w_file2 type string, w_file1 type string.parameters: filename like rlgrap-filename.parameters: filenam1 like rlgrap-filename.

at selection-screen on value-request for filename. call function 'F4_FILENAME' importing file_name = filename.

at selection-screen on value-request for filenam1. call function 'F4_FILENAME' importing file_name = filenam1.

start-of-selection.

w_file2 = filename. w_file1 = filenam1.*************** HEADER ************************ call function 'GUI_UPLOAD' exporting filename = w_file2 filetype = 'ASC' has_field_separator = 'X' tables

data_tab = it_head.

*************** Item *******************

call function 'GUI_UPLOAD' exporting filename = w_file1 filetype = 'ASC' has_field_separator = 'X' tables data_tab = it_item.

perform open_group. loop at it_head into wa_head..perform bdc_dynpr using 'SAPMV45A' '0101'.perform bdc_fiel using 'BDC_CURSOR' 'VBAK-AUART'.perform bdc_fiel using 'BDC_OKCODE' '/00'.perform bdc_fiel using 'VBAK-AUART' wa_head-auart.perform bdc_fiel using 'VBAK-VKORG' wa_head-vkorg.perform bdc_fiel using 'VBAK-VTWEG' wa_head-vtweg.perform bdc_fiel using 'VBAK-SPART' wa_head-spart.perform bdc_dynpr using 'SAPMV45A' '4001'.perform bdc_fiel using 'BDC_OKCODE' '/00'.perform bdc_fiel using 'VBKD-BSTKD' wa_head-bstkd.perform bdc_fiel using 'VBKD-BSTDK' '30.01.2006'.perform bdc_fiel using 'KUAGV-KUNNR' wa_head-kunnr.perform bdc_fiel using 'RV45A-KETDAT' '30.01.2006'.perform bdc_fiel using 'RV45A-KPRGBZ' 'D'.perform bdc_fiel using 'VBKD-ZTERM' '0001'.perform bdc_fiel using 'VBKD-INCO1' 'CIF'.perform bdc_fiel using 'VBKD-INCO2' 'COST INSUSRABCE FRIEGHT'.

loop at it_item into wa_item .concatenate 'RV45A-MABNR(' '0' val ')' into v_mabnr. concatenate 'RV45A-KWMENG(' '0' val ')' into v_kwmeng.

perform bdc_fiel using 'BDC_CURSOR' v_kwmeng.perform bdc_fiel using v_mabnr wa_item-matnr.perform bdc_fiel using v_kwmeng wa_item-kwmeng.

perform bdc_dynpr using 'SAPMV45A' '4001'.perform bdc_fiel using 'BDC_OKCODE' '/00'.

val = val + 1.if val > 5. val = 5.endif. endloop.val = 01.

perform bdc_dynpr using 'SAPMV45A' '4001'.perform bdc_fiel using 'BDC_OKCODE' '=SICH'.

perform bdc_transaction using 'VA01'. "MODE 'N' UPDATE 'S'endloop.

perform close_group.

*----------------------------------------------------------------------** Start new screen **----------------------------------------------------------------------*form bdc_dynpr using program dynpro. clear bdcdata. bdcdata-program = program. bdcdata-dynpro = dynpro. bdcdata-dynbegin = 'X'.

append bdcdata.endform.

*----------------------------------------------------------------------** Insert field **----------------------------------------------------------------------*form bdc_fiel using fnam fval. if fval <> nodata. clear bdcdata. bdcdata-fnam = fnam. bdcdata-fval = fval. append bdcdata. endif.endform.*&---------------------------------------------------------------------**& Report ZDEMO2*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zdemo2.

***************************************************************************************** Entra a la transaccion VA02 con los parametros de selección indicados* y le quita el bloqueo a este pedido.*El número de documento de ventas se manda a la VF01 y crea la factura correspondiente****************************************************************************************

tables: vbak, "Sales document, header data vbap. "Sales document, item data

data: begin of g_vbeln occurs 0,vbeln like vbak-vbeln,end of g_vbeln.

data: begin of bdc_tab occurs 0. include structure bdcdata.data: end of bdc_tab.

select-options:s_vbeln for vbak-vbeln, "Sales documents_audat for vbak-audat, "Document dates_auart for vbak-auart. "Sales document type

start-of-selection. perform get_data. perform remove_billingblock. perform bill_documents.******************************************************************** F O R M G E T _ D A T A*******************************************************************form get_data. select vbeln into corresponding fields of table g_vbeln from vbak where auart in s_auart and vbeln in s_vbeln and audat in s_audat. if sy-subrc > 0.

call function 'POPUP_TO_DISPLAY_TEXT' exporting* TITEL = ' ' textline1 = 'No sales documents found'* TEXTLINE2 = ' '

* START_COLUMN = 25* START_ROW = 6 exceptions others = 1. endif.endform. "GET_DATA

******************************************************************** F O R M R E M O V E _ B I L L I N G B L O C K* Quita Bloqueo a pedido indicado( Transaction VA02 )

*******************************************************************form remove_billingblock.

perform open_group.

refresh bdc_tab. clear bdc_tab.

loop at g_vbeln.* Selection screen perform bdc_newdynpro using 'SAPMV45A' '0102'. perform bdc_field using 'VBAK-VBELN' g_vbeln-vbeln. perform bdc_field using 'BDC_OKCODE' 'UER1'.* Screen 40001 perform bdc_newdynpro using 'SAPMV45A' '4001'. perform bdc_field using 'BDC_OKCODE' 'SFSP'.* Screen 0253 fast change of billingblock perform bdc_newdynpro using 'SAPMV45A' '0253'. perform bdc_field using 'RV45A-S_FAKSK' ' '. perform bdc_field using 'BDC_OKCODE' 'SUEB'.* Back to screen 4001 perform bdc_newdynpro using 'SAPMV45A' '4001'. perform bdc_field using 'BDC_OKCODE' 'SICH'.* Insert perform bdc_insert using 'VA02'.

clear bdc_tab. refresh bdc_tab. endloop.

perform close_group.endform. "REMOVE_BILLINGBLOCK

******************************************************************** F O R M B I L L _ D O C U M E N T S* Crea factura de pedido desbloqueado ( Transaction VF01 )*******************************************************************form bill_documents.

data: l_nline type i, l_cline(3) type n, l_fieldname(20) type c.

perform open_group.

refresh bdc_tab. clear bdc_tab. clear l_nline. clear l_cline.

perform bdc_newdynpro using 'SAPMV60A' '0102'. perform bdc_field using 'BDC_OKCODE' 'ENT1'.

loop at g_vbeln. l_nline = l_nline + 1.

if l_nline > 16.* The screentable is filled, go to next page perform bdc_field using 'BDC_OKCODE' '=P+'. endif.

* Convert linenumber to text move l_nline to l_cline. concatenate 'KOMFK-VBELN(' l_cline ')' into l_fieldname.

perform bdc_field using 'BDC_CURSOR' l_fieldname. perform bdc_field using l_fieldname g_vbeln-vbeln. perform bdc_field using 'BDC_OKCODE' 'ENT2'.

endloop.

* Close screen 0102 perform bdc_field using 'BDC_OKCODE' '/11'.

* Insert perform bdc_insert using 'VF01'.

clear bdc_tab. refresh bdc_tab.

perform close_group.

endform. "BILL_DOCUMENTS

******************************************************************** F O R M B D C _ D Y N P R O* Start a new screen*******************************************************************form bdc_newdynpro using program dynpro. clear bdc_tab. bdc_tab-program = program. bdc_tab-dynpro = dynpro. bdc_tab-dynbegin = 'X'. append bdc_tab.endform. "BDC_NEWDYNPRO

******************************************************************** F O R M B D C _ F I E L D* Inserts a field*******************************************************************form bdc_field using fnam fval. clear bdc_tab. bdc_tab-fnam = fnam. bdc_tab-fval = fval. append bdc_tab.endform. "BDC_FIELD

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

* F O R M O P E N _ G R O U P*******************************************************************form open_group.

call function 'BDC_OPEN_GROUP' exporting client = sy-mandt* DEST = FILLER8 group = 'ZSM02'* HOLDDATE = FILLER8 keep = 'X' user = sy-uname* RECORD = FILLER1* IMPORTING* QID = exceptions client_invalid = 1 destination_invalid = 2 group_invalid = 3 group_is_locked = 4

holddate_invalid = 5 internal_error = 6 queue_error = 7 running = 8 system_lock_error = 9 user_invalid = 10 others = 11.endform. "OPEN_GROUP

******************************************************************** F O R M C L O S E _ G R O U P*******************************************************************

form close_group. call function 'BDC_CLOSE_GROUP' exceptions not_open = 1 queue_error = 2 others = 3.endform. "CLOSE_GROUP

*&---------------------------------------------------------------------**& Form BDC_INSERT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->TCODE text*----------------------------------------------------------------------*form bdc_insert using tcode. call function 'BDC_INSERT' exporting tcode = tcode* POST_LOCAL = NOVBLOCAL* PRINTING = NOPRINT tables dynprotab = bdc_tab exceptions internal_error = 1 not_open = 2 queue_error = 3 tcode_invalid = 4 printing_invalid = 5 posting_invalid = 6 others = 7.

endform. "BDC_INSERT

*&---------------------------------------------------------------------**& Report ZEX*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

**EJEMPLO 1

report zex.

tables: ekko.

type-pools: slis. "ALV Declarations*Data Declarationtypes: begin of t_ekko, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, statu type ekpo-statu, aedat type ekpo-aedat,

matnr type ekpo-matnr, menge type ekpo-menge, meins type ekpo-meins, netpr type ekpo-netpr, peinh type ekpo-peinh, end of t_ekko.

data: it_ekko type standard table of t_ekko initial size 0, wa_ekko type t_ekko.

*data: zcurr(8) type p decimals 2.

*ALV data declarationsdata: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid.

start-of-selection.start-of-selection.

perform data_retrieval.perform build_fieldcatalog.perform build_layout.perform display_alv_report.

*&---------------------------------------------------------------------**& Form BUILD_FIELDCATALOG*&---------------------------------------------------------------------** Build Fieldcatalog for ALV Report*----------------------------------------------------------------------*form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'. fieldcatalog-seltext_m = 'Purchase Order'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'. fieldcatalog-do_sum = 'X'. fieldcatalog-no_zero = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'. fieldcatalog-seltext_m = 'PO Item'. fieldcatalog-col_pos = 1. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'. fieldcatalog-seltext_m = 'Status'. fieldcatalog-col_pos = 2. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'. fieldcatalog-seltext_m = 'Item change date'. fieldcatalog-col_pos = 3. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'. fieldcatalog-seltext_m = 'Material Number'. fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'. fieldcatalog-seltext_m = 'PO quantity'. fieldcatalog-col_pos = 5. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'. fieldcatalog-seltext_m = 'Order Unit'. fieldcatalog-col_pos = 6. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'. fieldcatalog-seltext_m = 'Net Price'. fieldcatalog-col_pos = 7. fieldcatalog-outputlen = 15. fieldcatalog-do_sum = 'X'. "Display column total fieldcatalog-datatype = 'CURR'. append fieldcatalog to fieldcatalog. clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'. fieldcatalog-seltext_m = 'Price Unit'. fieldcatalog-col_pos = 8. append fieldcatalog to fieldcatalog. clear fieldcatalog.endform. " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------**& Form BUILD_LAYOUT*&---------------------------------------------------------------------** Build layout for ALV grid report*----------------------------------------------------------------------*form build_layout. gd_layout-no_input = 'X'. gd_layout-colwidth_optimize = 'X'. gd_layout-totals_text = 'Totals'(201). gd_layout-totals_only = 'X'. gd_layout-f2code = 'DISP'. "Sets fcode for when double "click(press f2) gd_layout-zebra = 'X'. gd_layout-group_change_edit = 'X'. gd_layout-header_text = 'helllllo'.endform. " BUILD_LAYOUT

*&---------------------------------------------------------------------**& Form DISPLAY_ALV_REPORT*&---------------------------------------------------------------------** Display report using ALV grid*----------------------------------------------------------------------*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'* i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[]* it_special_groups = gd_tabgroup* IT_EVENTS = GT_XEVENTS i_save = 'X'* is_variant = z_template

tables t_outtab = it_ekko 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 DATA_RETRIEVAL*&---------------------------------------------------------------------** Retrieve data form EKPO table and populate itab it_ekko*----------------------------------------------------------------------*form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh up to 20 rows from ekpo into table it_ekko.endform. " DATA_RETRIEVAL

**************************************************************************************************************************************************************+

**EJEMPLO 2 ALV***&---------------------------------------------------------------------***& Report ZGUMM**&**&---------------------------------------------------------------------***&**&**&---------------------------------------------------------------------***REPORT z_alv_dynamic_data_v2.*DATA:* g_mandt TYPE mandt.**SELECTION-SCREEN :*BEGIN OF LINE, COMMENT 6(33) v_1 FOR FIELD p_table. "#EC NEEDED*PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY MEMORY ID dtb.*SELECTION-SCREEN : END OF LINE, SKIP.**SELECTION-SCREEN :*BEGIN OF LINE, COMMENT 6(30) v_2 FOR FIELD s_mandt. "#EC NEEDED*SELECT-OPTIONS s_mandt FOR g_mandt DEFAULT sy-mandt* MATCHCODE OBJECT ddsef4clnt.*SELECTION-SCREEN : END OF LINE, SKIP.**SELECTION-SCREEN :*SKIP , BEGIN OF LINE, COMMENT 6(33) v_3 FOR FIELD p_max. "#EC NEEDED*PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.*SELECTION-SCREEN END OF LINE.***---------------------------------------------------------------------**AT SELECTION-SCREEN.** PERFORM f_check_table.***---------------------------------------------------------------------**INITIALIZATION.** v_1 = 'Table'.* v_2 = 'Client'.

* v_3 = 'Maximum of records'.***---------------------------------------------------------------------**START-OF-SELECTION.** PERFORM f_display_data.***---------------------------------------------------------------------*** Form F_DISPLAY_DATA**---------------------------------------------------------------------**FORM f_display_data.** TYPE-POOLS: slis. " ALV Global Types** DATA:* lp_table TYPE REF TO data, " Pointer to dynamic table* ls_layout TYPE slis_layout_alv,* lt_fieldcat TYPE slis_t_fieldcat_alv.** FIELD-SYMBOLS :* <lt_data> TYPE STANDARD TABLE. " Data to display*** Create internal table* CREATE DATA lp_table TYPE STANDARD TABLE OF (p_table)* WITH NON-UNIQUE DEFAULT KEY.* ASSIGN lp_table->* TO <lt_data>.*** Field MANDT exists ?* SELECT SINGLE tabname* INTO p_table* FROM dd03l* WHERE tabname = p_table* AND fieldname = 'MANDT'* AND as4local = 'A'* AND as4vers = '0000'* AND position = '0001'* AND rollname = 'MANDT'.* IF sy-subrc EQ 0.** Read data* SELECT * UP TO p_max ROWS* FROM (p_table) CLIENT SPECIFIED* INTO CORRESPONDING FIELDS OF TABLE <lt_data>* WHERE mandt IN s_mandt* ORDER BY PRIMARY KEY.* ELSE.** Field CLIENT exists ?* SELECT SINGLE tabname* INTO p_table* FROM dd03l* WHERE tabname = p_table* AND fieldname = 'CLIENT'* AND as4local = 'A'* AND as4vers = '0000'* AND position = '0001'* AND rollname = 'MANDT'.* IF sy-subrc EQ 0.** Read data* SELECT * UP TO p_max ROWS* FROM (p_table) CLIENT SPECIFIED* INTO CORRESPONDING FIELDS OF TABLE <lt_data>* WHERE client IN s_mandt* ORDER BY PRIMARY KEY.* ELSE.** Read data* SELECT * UP TO p_max ROWS* FROM (p_table)* INTO CORRESPONDING FIELDS OF TABLE <lt_data>* ORDER BY PRIMARY KEY.* ENDIF.* ENDIF.

** IF <lt_data>[] IS INITIAL.** No table entries found for specified key* MESSAGE i429(mo).* EXIT.* ENDIF.*** Build Field catalog* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'* EXPORTING* i_structure_name = p_table* i_client_never_display = ''* CHANGING* ct_fieldcat = lt_fieldcat* EXCEPTIONS* inconsistent_interface = 1* program_error = 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.** ls_layout-zebra = 'X'.* ls_layout-colwidth_optimize = 'X'.*** Display ALV List* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'* EXPORTING* is_layout = ls_layout* it_fieldcat = lt_fieldcat* TABLES* t_outtab = <lt_data>.**ENDFORM. " F_DISPLAY_DATA**---------------------------------------------------------------------*** Form F_CHECK_TABLE**---------------------------------------------------------------------**FORM f_check_table.** DATA :* l_tabclass TYPE tabclass, " Table category* l_viewclass TYPE viewclass. " View Type*** Read table category* SELECT SINGLE tabclass viewclass* INTO (l_tabclass, l_viewclass)* FROM dd02l* WHERE tabname = p_table* AND as4local = 'A'* AND as4vers = '0000'.* IF sy-subrc NE 0.** Table & is not active in the Dictionary* MESSAGE e402(mo) WITH p_table.* ELSEIF l_tabclass = 'INTTAB'.** & is a structure, not a table* MESSAGE e403(mo) WITH p_table.* ELSEIF l_tabclass = 'VIEW' AND l_viewclass NE 'D'.** Only use views of type "Maintenance view"* MESSAGE e309(sv).* ENDIF.**ENDFORM. " F_CHECK_TABLE************************* FIN DU PROGRAMME Z_DYN ***********************

*&---------------------------------------------------------------------**& Module Pool ZMODULPOOL*&*&---------------------------------------------------------------------*

*&*&*&---------------------------------------------------------------------*

program zmodulpool.

tables: usr21, adrp.*&---------------------------------------------------------------------**& Module USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_0100 input.

case sy-ucomm.

when 'SALIR'.*Abandonar la dynrpo actual set screen 0. leave screen.

when 'BUSCAR'.*Buscar el código de usuario basandonos en el que se indique en pantalla select single * from usr21 where bname = usr21-bname.

*Si existe el usuario se buscara el nombre completo, de lo contrario se muesra el error if sy-subrc = 0.

select single * from adrp where persnumber = usr21-persnumber.

*Si no se encuentra se muestra mensaje de error. Y si existe no tengo que hacer nada por q automaticamente aparece*el nombre en el campo de la dynpro. Esto es por q hemos declarado el campo de la dynpro igual que el campo de la*tabla de la base de datos. if sy-subrc ne 0.

adrp-name_text = 'El usuario no existe'. endif. else. adrp-name_text = 'El usuario no existe'. endif.

when 'SAVE'.

*Guardar la info en alguna tabla

when 'CLEAR'.*Limpiar variablesclear: adrp-name_text, usr21-bname.

endcase.

endmodule. " USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------**& Module STATUS_0100 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module status_0100 output. set pf-status 'MPAINTER'. "En segundo lugar crear el menu painter (Nombre en mayusculas) set titlebar 'STB'. " Crear Set title bar primero (Nombre en mayusculas)

endmodule. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------**& Module Pool ZMODULPOOL2_BRF*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

program zmodulpool2_brf.

tables: ust10s.

data: t_ust10s like ust10s occurs 0 with header line, "guardara el resultado de buscar los objetos y autorizaciones de un determinado perfil i type i. "variable que controla los registros que pasamos al Step Loop*&---------------------------------------------------------------------**& Module ASIGNAR_DATOS OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module asignar_datos output.

*Es una asignacion simple debido a que la tabla t_ust10s tiene la misma estructura que la tabla ust10s

ust10s = t_ust10s.

endmodule. " ASIGNAR_DATOS OUTPUT*&---------------------------------------------------------------------**& Module USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_0100 input.

case sy-ucomm.

when 'SALIR'.

set screen 0. leave screen.

when 'BUSCAR'.

refresh: t_ust10s. clear: t_ust10s.

*Buscar en la tabla ust10s el perfil del campo PROFN de la dynpro y el *resultado lo guardo en la tabla internaselect * from ust10s into table t_ust10swhere profn = ust10s-profn.endcase.

endmodule. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------**& Report ZQQ*&*&---------------------------------------------------------------------**&*&

*&---------------------------------------------------------------------*

*REPORT ZQQ.

report zuploadexceldata .

types : begin of gty_currency, currencycode(5) type c, currencyname(50) type c, end of gty_currency.

data : currline type i, gs_exceldata type alsmex_tabline, gt_exceldata type table of alsmex_tabline, gs_currency type gty_currency, gt_currency type table of gty_currency.

* Import data from Excelcall function 'ALSM_EXCEL_TO_INTERNAL_TABLE' exporting filename = 'C:\currency.xls' i_begin_col = 1 i_begin_row = 1 i_end_col = 2 i_end_row = 1000 tables intern = gt_exceldata* EXCEPTIONS* INCONSISTENT_PARAMETERS = 1* UPLOAD_OLE = 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.

* Load data into internal tablecurrline = 0.sort gt_exceldata by row value.loop at gt_exceldata into gs_exceldata.

if currline = 0. currline = gs_exceldata-row. endif.

if currline <> gs_exceldata-row. currline = gs_exceldata-row. append gs_currency to gt_currency. endif.

case gs_exceldata-col. when 1. gs_currency-currencycode = gs_exceldata-value. when 2. gs_currency-currencyname = gs_exceldata-value. when others. endcase.

endloop.

* Display data write : / 'Code', 10 'Currency'.

loop at gt_currency into gs_currency.

write : / gs_currency-currencycode under 'Code', gs_currency-currencyname under 'Currency'.

endloop.

*&---------------------------------------------------------------------**& Report ZREPORTE_BRF*&*&---------------------------------------------------------------------**& Nombre: Beatriz Romero*$ Fecha: 7 dic 2011*& Descripción : Primer reporte de prueba GICSA*&---------------------------------------------------------------------*

report zreporte_brf.

tables: trdir.

selection-screen begin of block uno with frame title text-001. parameters: r_opt01 radiobutton group rad1, r_opt02 radiobutton group rad1, r_opt03 radiobutton group rad1, r_opt04 radiobutton group rad1.

selection-screen skip.

parameters: p_opt01 radiobutton group rad2 user-command aaa, p_opt02 radiobutton group rad2, p_opt03 radiobutton group rad2, p_opt04 radiobutton group rad2. selection-screen end of block uno.

selection-screen begin of block dos with frame title text-002. select-options: s_opt1 for trdir-cnam, s_opt22 for trdir-cnam, s_opt333 for trdir-cnam, s_opt444 for trdir-cnam. selection-screen end of block dos.

* AT SELECTION-SCREEN OUTPUT.** LOOP AT SCREEN.**---- Opción 1* IF r_opt01 = 'X'.* IF screen-name CS 'S_OPT1'.* screen-invisible = '0'.* screen-input = '1'.* ELSEIF screen-name CS 'S_OPT22' OR* screen-name CS 'S_OPT333' OR* screen-name CS 'S_OPT444' .* screen-invisible = '1'.* screen-input = '0'.* ENDIF.***---- Opción 2* ELSEIF p_opt02 = 'X'.* IF screen-name CS 'S_OPT22'.* screen-invisible = '0'.* screen-input = '1'.* ELSEIF screen-name CS 'S_OPT1' OR* screen-name CS 'S_OPT333' OR* screen-name CS 'S_OPT444' .

* screen-invisible = '1'.* screen-input = '0'.* ENDIF.***---- Opción 3* ELSEIF p_opt03 = 'X'.* IF screen-name CS 'S_OPT333'.* screen-invisible = '0'.* screen-input = '1'.* ELSEIF screen-name CS 'S_OPT1' OR* screen-name CS 'S_OPT22' OR* screen-name CS 'S_OPT444' .* screen-invisible = '1'.* screen-input = '0'.* ENDIF.***---- Opción 4* ELSEIF p_opt04 = 'X'.* IF screen-name CS 'S_OPT444'.* screen-invisible = '0'.* screen-input = '1'.* ELSEIF screen-name CS 'S_OPT1' OR* screen-name CS 'S_OPT22' OR* screen-name CS 'S_OPT333' .* screen-invisible = '1'.* screen-input = '0'.* ENDIF.* ENDIF.* MODIFY SCREEN.* ENDLOOP.

*&---------------------------------------------------------------------**& Report ZSERVIDOR*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zservidor.

parameter: p_path(100) default 'E:\usr\sap\EC1\DVEBMGS00\data\tbxstat'.*'E:\USR\SAP\EC1\DVEBMGS00\DATA\E0001OAC.DAT'.

* 'E:\usr\sap\EC1\DVEBMGS00\data\tbxstat'.

*DATA: BEGIN OF ti_registros OCCURS 0,*reg LIKE file_table-filename.*DATA: END OF ti_registros.

types: begin of t_registros,reg like file_table-filename.types: end of t_registros.

data: ti_registros type table of t_registros with header line.data: wa_reg type t_registros.

*OPEN DATASET p_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.open dataset p_path for input in legacy text mode.if sy-subrc ne 0. write:/ ' Error no se puede abrir el fichero'.else. do. clear ti_registros. read dataset p_path into ti_registros.

if sy-subrc = 0. append ti_registros. else. exit. endif. enddo.

close dataset p_path.endif.

loop at ti_registros into wa_reg.

write wa_reg-reg. endloop.

*&---------------------------------------------------------------------**& Report ZSMART1*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zsmart1.

tables: mkpf.* ----------------------------------------------------------------------* Nombre del modulo de funciones del formulario.data: /1bcdwb/sf00000152 type rs38l_fnam.

* Tabla auxiliar para los datos.data: begin of aux_mkpf occurs 0. include structure mkpf.data: end of aux_mkpf.* ----------------------------------------------------------------------* Programa principalperform cargar_datos_demo.perform invocar_smartform.exit.* ----------------------------------------------------------------------form cargar_datos_demo.* Limpiar las tablas auxiliares antes de usarlas. clear aux_mkpf. refresh aux_mkpf.* Cargar los 10 primeros registros para probar. select * into table aux_mkpf from mkpf.endform. "cargar_datos_demo* ----------------------------------------------------------------------form invocar_smartform.* Inicializar el formulario. call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'ZIMAGEN' importing fm_name = /1bcdwb/sf00000152 exceptions no_form = 1 no_function_module = 2 others = 3.* Si hubo errores, desplegar mensaje y terminar, si se continua se* produce un error de run time. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.* Enviar datos al formulario e imprimirlo. call function '/1BCDWB/SF00000152' tables gs_mkpf = aux_mkpf exceptions formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 others = 5.* Si se produce un error, controlarlo 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. "invocar_smartform* ---------------------------------------------------

*&---------------------------------------------------------------------**& Report ZSOL*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

*REPORT ZSOL.

program zsol no standard page heading.

data: number like datatype-integer2.data: dummy like datatype-integer2.data: begin of cards occurs 52 , entry type i, row type i, col type i, vis(1), end of cards.data: card_num type i, suit_num type i, suit(1), card(2), rows type i.data: blank(3) value '***'.data: next-card(4) value 'Next'.data: restart(8) value 'New game'.data: reveal(6) value 'Reveal'.data: test_num type i, to_num type i, moving_num type i, pile_num type i.data: curr_c type i, curr_h type i, curr_s type i, curr_d type i.data: moving_suit(1), to_suit(1), moving_card(2), to_card(2), pile_suit(1), pile_card(2),moving_type(1) .data: moving_row type i, moving_col type i, to_row type i, to_col type i, test_row type i.data: current_card type i, min_card type i , max_card type i.data: currentfield(50).data: disc_c(3),disc_h(3),disc_s(3),disc_d(3).data: rows_out type i, cols_out type i.

perform shuffle.perform show_screen.

at line-selection. get cursor field currentfield. perform process-input.

*---------------------------------------------------------------------** FORM SHUFFLE *

*---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form shuffle. min_card = 3.max_card = 24. curr_c = -1.curr_d = -1.curr_h = -1.curr_s = -1. disc_c = 'CCC'.disc_h = 'HHH'.disc_s = 'SSS'.disc_d = 'DDD'. number = sy-uzeit mod 1000. do number times. call function 'RANDOM_I2' importing rnd_value = dummy. enddo. refresh cards. clear cards. sy-tabix = 0. while sy-tabix < 52.*do 40 times. call function 'RANDOM_I2' exporting rnd_min = 0 rnd_max = 51 importing rnd_value = number. read table cards with key number transporting no fields. if sy-subrc <> 0. cards-vis = 'n'. describe table cards lines rows. case rows. when 0.cards-vis = 'y'.cards-row = 0.cards-col = 0. when 7.cards-vis = 'y'.cards-row = 1.cards-col = 1. when 13.cards-vis = 'y'.cards-row = 2.cards-col = 2. when 18.cards-vis = 'y'.cards-row = 3.cards-col = 3. when 22.cards-vis = 'y'.cards-row = 4.cards-col = 4. when 25.cards-vis = 'y'.cards-row = 5.cards-col = 5. when 27.cards-vis = 'y'.cards-row = 6.cards-col = 6. when 28.cards-row = 20.cards-col = 0. endcase. cards-col = cards-col + 1. cards-entry = number. append cards. endif.*enddo. endwhile. current_card = min_card.endform.

*---------------------------------------------------------------------** FORM SHOW_SCREEN **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form show_screen. rows_out = 1. cols_out = 4. do 7 times. skip to line rows_out. position cols_out. write blank hotspot. cols_out = cols_out + 4. enddo. loop at cards. perform make_card. if cards-row < 20. rows_out = cards-row + 1. skip to line rows_out. cols_out = cards-col * 4. position cols_out. if cards-vis = 'n'. write 'XXX' color off intensified off inverse off. else. if suit = 'D' or suit = 'H'.

write: suit no-gap color 6 intensified inverse hotspot, card color 6 intensified inverse hotspot. else. write: suit no-gap color off intensified off inverse off hotspot, card color off intensified off inverse off hotspot. endif. endif. else. skip to line 20. cols_out = cards-col * 4. if cols_out > 48. skip to line 21. cols_out = cols_out - 48. endif. position cols_out. if cards-col = current_card. pile_suit = suit. pile_card = card. pile_num = card_num. if suit = 'D' or suit = 'H'. write: pile_suit no-gap color 6 intensified inverse hotspot, pile_card color 6 intensified inverse hotspot. else. write: pile_suit no-gap color off intensified off hotspot, pile_card color off intensified off hotspot. endif. else. if cards-col < current_card. write 'XXX' color off intensified off inverse off. endif. endif. endif. endloop. skip to line 4. position 40.write: disc_c color off intensified off inverse off hotspot. skip to line 4. position 44. write: disc_d color 6 intensified inverse hotspot. skip to line 4. position 48. write: disc_s color off intensified off inverse off hotspot. skip to line 4. position 52. write: disc_h color 6 intensified inverse hotspot. if min_card > 0. skip to line 23. position 1. write next-card hotspot. endif. skip to line 23. position 20. write restart hotspot.* skip to line 23. position 40. write reveal hotspot. skip to line 25. position 1. write currentfield. sy-lsind = 0.endform.

*---------------------------------------------------------------------** FORM PROCESS-INPUT **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form process-input. if currentfield = 'NEXT-CARD'. if current_card = max_card. current_card = min_card. else. current_card = current_card + 3. if current_card > max_card. current_card = max_card. endif. endif. moving_card = space. currentfield = space. perform show_screen. exit. endif. if currentfield = 'REVEAL'.

loop at cards. cards-vis = 'y'. modify cards. endloop. perform show_screen. exit. endif. if currentfield = 'RESTART'. perform shuffle. currentfield = 'Restarting'. perform show_screen. exit. endif. if moving_card = space. if currentfield = 'CARD' or currentfield = 'SUIT'. currentfield = space. rows_out = sy-curow - 1. cols_out = sy-cucol div 4. loop at cards. if cards-row = rows_out and cards-col = cols_out. currentfield = 'Moving '. perform make_card. moving_row = cards-row. moving_col = cards-col. moving_card = card. moving_suit = suit. moving_type = 'm'. moving_num = card_num. currentfield+8(1) = suit. currentfield+9(2) = card. endif. endloop. else. if currentfield = 'PILE_CARD' or currentfield = 'PILE_SUIT'. moving_card = pile_card. moving_suit = pile_suit. moving_type = 'p'. moving_num = pile_num. currentfield = 'Moving pile card'. currentfield+17(1) = pile_suit. currentfield+18(2) = pile_card. else. currentfield = space. endif. endif. else. if currentfield = 'CARD' or currentfield = 'SUIT' or currentfield = 'BLANK'. rows_out = sy-curow - 1. cols_out = sy-cucol div 4. test_row = -1. if currentfield = 'BLANK'. to_col = cols_out. to_row = rows_out - 1. if moving_card = 'K'. perform move_card. else. currentfield = 'Can only move K to blank'. moving_card = space. endif. else. loop at cards. if ( cards-row >= test_row and cards-row < 20 ) and cards-col = cols_out. test_row = cards-row. perform make_card. to_col = cards-col. to_row = cards-row. to_card = card. to_suit = suit.

to_num = card_num. endif. endloop. if to_col <> moving_col or moving_type = 'p'. if ( ( moving_suit = 'D' or moving_suit = 'H' ) and ( to_suit = 'D' or to_suit = 'H' ) ) or ( ( moving_suit = 'C' or moving_suit = 'S' ) and ( to_suit = 'S' or to_suit = 'S' ) ). currentfield = 'Can only put black on red or red on black'. moving_card = space. else. test_num = to_num - 1. if test_num = moving_num. perform move_card. else. currentfield = 'Can only put on next higher card'. moving_card = space. endif. endif. else. currentfield = 'Can only move to another column'. moving_card = space. endif. endif. else. if currentfield(4) = 'DISC'. to_suit = currentfield+5(1). if moving_type = 'p'. else. test_row = -1. loop at cards. if cards-col = moving_col and cards-row > test_row and cards-row < 20. test_row = cards-row. perform make_card. moving_suit = suit. moving_card = card. moving_row = cards-row. moving_col = cards-col. moving_num = card_num. endif. endloop. endif. if moving_suit = to_suit. case moving_suit. when 'C'. test_num = curr_c + 1. when 'H'. test_num = curr_h + 1. when 'D'. test_num = curr_d + 1. when 'S'. test_num = curr_s + 1. endcase. if test_num = moving_num. perform discard_card. case moving_suit. when 'C'. curr_c = curr_c + 1. when 'D'. curr_d = curr_d + 1. when 'S'. curr_s = curr_s + 1. when 'H'. curr_h = curr_h + 1. endcase. else. currentfield = 'Can only discard on next lower card'. moving_card = space. endif. else. moving_card = space. currentfield = 'Can only discard on same suit'. endif. else. moving_card = space.

currentfield = space. endif. endif. endif. perform show_screen.endform.*---------------------------------------------------------------------** FORM MAKE_CARD **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form make_card. suit_num = cards-entry div 13 . case suit_num. when 0.suit = 'D'. when 1.suit = 'H'. when 2.suit = 'C'. when 3.suit = 'S'. endcase. card_num = cards-entry mod 13. case card_num. when 0.card = 'A'. when 1.card = '2'. when 2.card = '3'. when 3.card = '4'. when 4.card = '5'. when 5.card = '6'. when 6.card = '7'. when 7.card = '8'. when 8.card = '9'. when 9.card = '10'. when 10.card = 'J'. when 11.card = 'Q'. when 12.card = 'K'. endcase.endform.*---------------------------------------------------------------------** FORM MOVE_CARD **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form move_card. if currentfield <> 'BLANK'. currentfield = 'Moving xxx to'. move moving_suit to currentfield+7(1). move moving_card to currentfield+8(2). move to_suit to currentfield+14(1). move to_card to currentfield+15(2). else. currentfield = 'Starting emtpy column'. endif. if moving_type = 'p'. move 'from pile' to currentfield+18. loop at cards. if cards-row = 20 and cards-col = current_card. cards-col = to_col. cards-row = to_row + 1. cards-vis = 'y'. endif. if cards-row = 20 and cards-col > current_card. cards-col = cards-col - 1. endif. modify cards. endloop. current_card = current_card - 1. max_card = max_card - 1. if max_card < min_card. min_card = min_card - 1. max_card = min_card. endif.

if current_card < 1. current_card = min_card. endif. else. loop at cards. if cards-col = moving_col and ( cards-row >= moving_row and cards-row < 20 ). cards-col = to_col. cards-row = to_row + 1 + cards-row - moving_row. modify cards. endif. endloop. test_row = moving_row - 1. loop at cards. if cards-col = moving_col and cards-row = test_row. cards-vis = 'y'. modify cards. endif. endloop. endif. moving_card = space.endform.*---------------------------------------------------------------------** FORM DISCARD_CARD **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*form discard_card. move 'Discarding' to currentfield. move moving_suit to currentfield+13(1). move moving_card to currentfield+14(2). case to_suit. when 'C'. disc_c+1(2) = moving_card. when 'D'. disc_d+1(2) = moving_card. when 'H'. disc_h+1(2) = moving_card. when 'S'. disc_s+1(2) = moving_card. endcase. if moving_type = 'p'. move 'from pile' to currentfield+18. loop at cards. if cards-row = 20 and cards-col = current_card. cards-col = 0. endif. if cards-row = 20 and cards-col > current_card. cards-col = cards-col - 1. endif. modify cards. endloop. current_card = current_card - 1. max_card = max_card - 1. if max_card < min_card. min_card = min_card - 1. max_card = min_card. endif. if current_card < 1. current_card = min_card. endif. else. loop at cards. if cards-row = moving_row and cards-col = moving_col. cards-col = 0. modify cards. endif. endloop. test_row = moving_row - 1. loop at cards.

if cards-col = moving_col and cards-row = test_row. cards-vis = 'y'. modify cards. endif. endloop. endif. moving_card = space.endform.

*&---------------------------------------------------------------------**& Report ZTC_BRF*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report ztc_brf.

tables: ekko.

data: mark type c.controls: tc100 type tableview using screen 100.

data: ok_code type sy-ucomm.data: it_ekko type standard table of ekko initial size 0, wa_ekko type ekko.*&---------------------------------------------------------------------**& Module DATA_RETRIEVAL OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module data_retrieval output.

select ebeln bukrs bstyp bsart bsakz loekz statu aedat up to 10 rows from ekko into corresponding fields of table it_ekko.

endmodule. " DATA_RETRIEVAL OUTPUT*&---------------------------------------------------------------------**& Module POPULATE_SCREEN OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module populate_screen output.

data: ld_line type i.

* linea de table es el top de la tabla de control mostrada if sy-stepl = 1. tc100-lines = tc100-top_line + sy-loopc - 1. endif.

* move fields from work area to scrren fields move-corresponding wa_ekko to ekko.

describe table it_ekko lines tc100-current_line.

endmodule. " POPULATE_SCREEN OUTPUT*&---------------------------------------------------------------------**& Module USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_0100 input.

case sy-ucomm.

when 'SALIR'.*Abandonar la dynrpo actual set screen 0. leave screen.

endcase.endmodule. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------**& Report ZUP*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zup.

type-pools: truxs.

parameters: p_file type rlgrap-filename.

types: begin of t_datatab, col1(30) type c, col2(30) type c, col3(30) type c, end of t_datatab.data: it_datatab type standard table of t_datatab, wa_datatab type t_datatab.

data: it_raw type truxs_t_text_data.

* At selection screenat selection-screen on value-request for p_file. call function 'F4_FILENAME' exporting field_name = 'P_FILE' importing file_name = p_file.

************************************************************************START-OF-SELECTION.start-of-selection.

call function 'TEXT_CONVERT_XLS_TO_SAP' "alsm_excel_to_internal_table exporting* I_FIELD_SEPERATOR = i_line_header = 'X' "Con esta línea de código indicamos si el archivo a cargar tendran nombres las "columnas a crear i_tab_raw_data = it_raw " WORK TABLE i_filename = p_file tables i_tab_converted_data = it_datatab[] "ACTUAL DATA exceptions conversion_failed = 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.

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

* END-OF-SELECTION.end-of-selection. loop at it_datatab into wa_datatab. write:/ wa_datatab-col1, wa_datatab-col2, wa_datatab-col3. endloop.

*&---------------------------------------------------------------------**& Report ZTABLA_CTRL_RTO*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report ztabla_ctrl_rto.

tables: vbak, vbap.

data: it_vbak type standard table of vbak with header line, it_vbap type standard table of vbap with header line, wa_it_vbak type vbak, wa_it_vbap type vbap, i type i.

types: begin of t_vbak_vbap, hdr(1) type c, vbeln type vbak-vbeln, erdat type vbak-erdat, netwr type vbak-netwr, line(1) type c, posnr type vbap-posnr, matnr type vbap-matnr, posar type vbap-posar, zwert type vbap-zwert.types: end of t_vbak_vbap.

data: it_vbak_vbap type standard table of t_vbak_vbap with header line, wa_it_vbak_vbap type t_vbak_vbap.

controls: tc1 type tableview using screen '9000'.

*&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_9000 input.

case sy-ucomm. when 'SALIR'. set screen 0. leave screen.

when 'LLENAR'. perform llenado.

endcase.

endmodule. " USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------**& Module STATUS_9000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*

module status_9000 output.* SET PF-STATUS 'xxxxxxxx'.* SET TITLEBAR 'xxx'.

* PERFORM llenado.

endmodule. " STATUS_9000 OUTPUT*&---------------------------------------------------------------------**& Form LLENADO*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*form llenado .

select * into table it_vbak from vbak.

select * into table it_vbapfrom vbapfor all entries in it_vbakwhere vbeln = it_vbak-vbeln.

loop at it_vbak into wa_it_vbak.

if sy-subrc = 0. wa_it_vbak_vbap-hdr = 'C'. wa_it_vbak_vbap-vbeln = wa_it_vbak-vbeln. wa_it_vbak_vbap-erdat = wa_it_vbak-erdat. wa_it_vbak_vbap-netwr = wa_it_vbak-netwr. wa_it_vbak_vbap-line = ''. wa_it_vbak_vbap-posnr = ''. wa_it_vbak_vbap-matnr = ''. wa_it_vbak_vbap-posar = ''. wa_it_vbak_vbap-zwert = ''.

append wa_it_vbak_vbap to it_vbak_vbap.

endif. loop at it_vbap into wa_it_vbap where vbeln = wa_it_vbak-vbeln.

if sy-subrc = 0.

wa_it_vbak_vbap-hdr = ''. wa_it_vbak_vbap-vbeln = ''. wa_it_vbak_vbap-erdat = ''. wa_it_vbak_vbap-netwr = 0. wa_it_vbak_vbap-line = 'L'. wa_it_vbak_vbap-posnr = wa_it_vbap-posnr. wa_it_vbak_vbap-matnr = wa_it_vbap-matnr. wa_it_vbak_vbap-posar = wa_it_vbap-posar. wa_it_vbak_vbap-zwert = wa_it_vbap-zwert.

append wa_it_vbak_vbap to it_vbak_vbap.

endif.

endloop.endloop.

endform. " LLENADO

*&---------------------------------------------------------------------**& Report ZREPORTE_FORM_RTO*&*&---------------------------------------------------------------------*

*&*&*&---------------------------------------------------------------------*

report zreporte_form_rto.

tables: bkpf, bseg,kna1.

data: it_bkpf type standard table of bkpf with header line, it_bseg type standard table of bseg with header line, it_kna1 type standard table of kna1 with header line, wa_it_bkpf type bkpf, wa_it_bseg type bseg, wa_it_kna1 type kna1, belnr type bkpf-belnr, /1bcdwb/sf00000160 type rs38l_fnam.

data: it_bkpf_bseg type ztabkpf_bseg_rto, wa_it_bkpf_bseg type ztbkpf_bseg_rto.

parameters: l_bukrs type bkpf-bukrs default '0001', l_belnr type bkpf-belnr default '100000001', l_gjahr type bkpf-gjahr default '2012'.

select * into table it_bkpf from bkpf where bukrs = l_bukrs and belnr = l_belnr and gjahr = l_gjahr.select * into table it_bsegfrom bsegfor all entries in it_bkpfwhere belnr = it_bkpf-belnr and bukrs = it_bkpf-bukrs and gjahr = it_bkpf-gjahr.

select * into table it_kna1from kna1for all entries in it_bsegwhere kunnr = it_bseg-kunnr.

loop at it_bkpf into wa_it_bkpf. loop at it_bseg into wa_it_bseg. read table it_kna1 into wa_it_kna1 with key kunnr = wa_it_bseg-kunnr.

if sy-subrc = 0.

wa_it_bkpf_bseg-belnr = wa_it_bkpf-belnr. wa_it_bkpf_bseg-awkey = wa_it_bkpf-awkey. wa_it_bkpf_bseg-bldat = wa_it_bkpf-bldat. wa_it_bkpf_bseg-fpayment(25) = 'Pago en una sola Exhibición'. wa_it_bkpf_bseg-eanred = 'GRUPO '. wa_it_bkpf_bseg-ename1 = 'CABI ADMINISTRADORA'. wa_it_bkpf_bseg-ename2 = ''. wa_it_bkpf_bseg-eort01 = 'México D.F'. wa_it_bkpf_bseg-kunnr = wa_it_bseg-kunnr. wa_it_bkpf_bseg-anred = wa_it_kna1-anred. wa_it_bkpf_bseg-name1 = wa_it_kna1-name1. wa_it_bkpf_bseg-name2 = wa_it_kna1-name2. wa_it_bkpf_bseg-ort01 = wa_it_kna1-ort01. wa_it_bkpf_bseg-yearapp(4) = '2011'. wa_it_bkpf_bseg-noapp(5) = '01234'. wa_it_bkpf_bseg-quaty = '1'. wa_it_bkpf_bseg-sgtxt = wa_it_bseg-sgtxt. wa_it_bkpf_bseg-pswbt = wa_it_bseg-pswbt. wa_it_bkpf_bseg-tswbt = wa_it_bseg-pswbt * wa_it_bkpf_bseg-quaty.

append wa_it_bkpf_bseg to it_bkpf_bseg.

endif.

endloop.endloop.

*belnr = '12345'.

call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'ZSMART_FORMS_RTO'* VARIANT = ' '* DIRECT_CALL = ' ' importing fm_name = /1bcdwb/sf00000160* EXCEPTIONS* NO_FORM = 1* NO_FUNCTION_MODULE = 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.

call function '/1BCDWB/SF00000160' exporting* ARCHIVE_INDEX =* ARCHIVE_INDEX_TAB =* ARCHIVE_PARAMETERS =* CONTROL_PARAMETERS =* MAIL_APPL_OBJ =* MAIL_RECIPIENT =* MAIL_SENDER =* OUTPUT_OPTIONS =* USER_SETTINGS = 'X' h_bkpf_bseg = wa_it_bkpf_bseg* IMPORTING* DOCUMENT_OUTPUT_INFO =* JOB_OUTPUT_INFO =* JOB_OUTPUT_OPTIONS = tables git_bkpf_bseg = it_bkpf_bseg* EXCEPTIONS* FORMATTING_ERROR = 1* INTERNAL_ERROR = 2* SEND_ERROR = 3* USER_CANCELED = 4* OTHERS = 5 .if sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.endif.

*CALL FUNCTION '/1BCDWB/SF00000160'* EXPORTING* ARCHIVE_INDEX =* ARCHIVE_INDEX_TAB =* ARCHIVE_PARAMETERS =* CONTROL_PARAMETERS =* MAIL_APPL_OBJ =* MAIL_RECIPIENT =* MAIL_SENDER =* OUTPUT_OPTIONS =* USER_SETTINGS = 'X'* IMPORTING* DOCUMENT_OUTPUT_INFO =* JOB_OUTPUT_INFO =

* JOB_OUTPUT_OPTIONS =* TABLES* GIT_BKPF_BSEG = it_bkpf_bseg* EXCEPTIONS* FORMATTING_ERROR = 1* INTERNAL_ERROR = 2* SEND_ERROR = 3* USER_CANCELED = 4* OTHERS = 5* .*IF SY-SUBRC <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*ENDIF.

*CALL FUNCTION '/1BCDWB/SF00000160'* EXPORTING** ARCHIVE_INDEX =** ARCHIVE_INDEX_TAB =** ARCHIVE_PARAMETERS =** CONTROL_PARAMETERS =** MAIL_APPL_OBJ =** MAIL_RECIPIENT =** MAIL_SENDER =** OUTPUT_OPTIONS =** USER_SETTINGS = 'X'* BELNR = belnr** IMPORTING** DOCUMENT_OUTPUT_INFO =** JOB_OUTPUT_INFO =** JOB_OUTPUT_OPTIONS =** EXCEPTIONS** FORMATTING_ERROR = 1** INTERNAL_ERROR = 2** SEND_ERROR = 3** USER_CANCELED = 4** OTHERS = 5* .*IF SY-SUBRC <> 0.** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*ENDIF.

*&---------------------------------------------------------------------**& Report ZREPORTE_EXCELFINAL_RTO*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zreporte_excelfinal_rto.

type-pools: truxs.tables: kna1.

types: begin of t_kna1, zcliente type kna1-kunnr, zpais type kna1-land1, zname type name1, zcity type ort01, zcp type pstlz, zregion type regio, zcalle type stras,

ztel type telf1, end of t_kna1.

data: it_table type standard table of t_kna1 with header line, it_raw type truxs_t_text_data, it_wa_aux type t_kna1, it_wa_table type standard table of kna1 with header line.

*selection-screen begin of block uno with frame title text-001.parameters: "z_opt01 radiobutton group rad1, l_file type rlgrap-filename default 'C:\Users\rmartinez\Desktop\SAP\Curso GICSA\Repaso ABAP\Datos Clientes - KNA1.xlsx'.**selection-screen skip 2.**parameters z_opt02 radiobutton group rad1.**selection-screen end of block uno.

** LOOP at screen.**---- Opcion 1* if z_opt01 = 'X'.

* At selection screenat selection-screen on value-request for l_file. call function 'F4_FILENAME' exporting field_name = 'P_FILE' importing file_name = l_file.

*START-OF-SELECTION call function 'TEXT_CONVERT_XLS_TO_SAP' exporting* I_FIELD_SEPERATOR = i_line_header = 'X' i_tab_raw_data = it_raw i_filename = l_file tables i_tab_converted_data = it_table exceptions conversion_failed = 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.

loop at it_table into it_wa_aux.

it_wa_table-kunnr = it_wa_aux-zcliente. it_wa_table-land1 = it_wa_aux-zpais. it_wa_table-name1 = it_wa_aux-zname. it_wa_table-ort01 = it_wa_aux-zcity. it_wa_table-pstlz = it_wa_aux-zcp. it_wa_table-regio = it_wa_aux-zregion. it_wa_table-stras = it_wa_aux-zcalle. it_wa_table-telf1 = it_wa_aux-ztel. it_wa_table-adrnr = '11111'.

append it_wa_table.

endloop.

*Lo mas recomendable cuando son muchos datos. insert kna1 from table it_wa_table.

if sy-subrc <> 0.endif.

* endif.*EndLOOP.

report zreportedatosmasivos no standard page heading line-size 255.

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'SAPMF02D' '0101'.perform bdc_field using 'BDC_CURSOR' 'RF02D-KUNNR'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'RF02D-KUNNR' '0000000100'.perform bdc_field using 'RF02D-D0110' 'X'.perform bdc_dynpro using 'SAPMF02D' '0110'.perform bdc_field using 'BDC_CURSOR' 'KNA1-TELF2'.perform bdc_field using 'BDC_OKCODE' '=UPDA'.perform bdc_field using 'KNA1-NAME1' 'Servicios de Limpieza'.perform bdc_field using 'KNA1-NAME2' 'y Mantenimiento'.perform bdc_field using 'KNA1-STRAS' 'Av. Comonfort 514'.perform bdc_field using 'KNA1-ORT01' 'MEXICO'.perform bdc_field using 'KNA1-PSTLZ' '04378'.perform bdc_field using 'KNA1-ORT02' 'Miguel Hidalgo'.perform bdc_field using 'KNA1-LAND1' 'MX'.perform bdc_field using 'KNA1-REGIO' 'DF'.perform bdc_field using 'KNA1-SPRAS' 'ES'.perform bdc_field using 'KNA1-TELF1' '(55) 34982364'.perform bdc_field using 'KNA1-TELF2' '(55) 23234545'.perform bdc_transaction using 'XD02'.

perform close_group.

*&---------------------------------------------------------------------**& Module Pool ZMPOOL_RTO*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

program zmpool_rto.

tables: ust04, usr11.

data: begin of t_perfiles occurs 300, profile like ust04-profile, texto like usr11-ptext, end of t_perfiles, i type i.

controls: tab1 type tabstrip, table type tableview using screen '9100'.*&---------------------------------------------------------------------**& Module USER_COMMAND_9200 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_9200 input.

case sy-ucomm. when 'BUSCAR'.

clear: t_perfiles. refresh: t_perfiles.

select * from ust04 where bname = ust04-bname.

t_perfiles-profile = ust04-profile.

select single * from usr11 where profn = ust04-profile and langu = sy-langu and aktps = 'A'.

if sy-subrc = 0. t_perfiles-texto = usr11-ptext. else. t_perfiles-texto = 'No hay descripción'. endif.

append t_perfiles.

endselect.

tab1-activetab = 'PERF'.

endcase.

endmodule. " USER_COMMAND_9200 INPUT*&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_9000 input.

case sy-ucomm. when 'SALIR'. set screen 0. leave screen.

when 'USU'. tab1-activetab = 'USU'.

when 'PERF'. tab1-activetab = 'PERF'. endcase.endmodule. " USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------**& Module STATUS_9200 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------**MODULE STATUS_9200 OUTPUT.* SET PF-STATUS 'MENU_ES'.* SET TITLEBAR 'TITULO'.*

*ENDMODULE. " STATUS_9200 OUTPUT*&---------------------------------------------------------------------**& Module STATUS_9000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module status_9000 output. set pf-status 'MENU_ES'. set titlebar 'TITULO'.

endmodule. " STATUS_9000 OUTPUT

*&---------------------------------------------------------------------**& Report ZLEERARCHIVO*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

report zleerarchivo.

parameter: p_path(100) default 'E:\usr\sap\PRFCLOG\dev_coll'.

types: begin of t_registros,reg like file_table-filename.types: end of t_registros.

data: ti_registros type table of t_registros with header line.data: wa_reg type t_registros.

*OPEN DATASET p_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.open dataset p_path for input in legacy text mode.if sy-subrc ne 0. write:/ ' Error no se puede abrir el fichero'.else. do. clear ti_registros. read dataset p_path into ti_registros. if sy-subrc = 0. append ti_registros. else. exit. endif. enddo.

close dataset p_path.endif.

loop at ti_registros into wa_reg.

write wa_reg-reg. endloop.

top related