Real estate business Entity Program

Published on March 2017 | Categories: Documents | Downloads: 53 | Comments: 0 | Views: 339
of 20
Download PDF   Embed   Report

Comments

Content

REPORT zre1_rebusentity_download NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-CO UNT 58. ************************************************************************ * Program : ZRE1_REBUSENTITY_DOWNLOAD * Author : chitturi venu * Date :28-04-2012 * Description : Business Entity * * Input Parameters :File Path,Template,Company Code,Object Validity,Site Number * Output Parameter : Business Entity,Company Code,Site Number * Updated Tables : None * Updated Files : None * ************************************************************************ * Modification History ************************************************************************ * Programmer Date Request # Description * MI_DEV06 dd/mm/yy EH5K900357 ownloading business entity data into di fferent excel sheets * ************************************************************************ TYPE-POOLS :abap, slis, ole2 . ************************************************************************ * I N C L U D E P R O G R A M S ************************************************************************ ************************************************************************ * D A T A E L E M E N T S ************************************************************************ DATA:v_bukrs TYPE bukrs, "Company Code v_swenr TYPE rebdbeno,"Site Number v_rerf TYPE rerf, "Entered by v_derf TYPE derf. "First Entered on ************************************************************************ * S E L E C T - O P T I O N S A N D P A R A M E T E R S ************************************************************************* SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 ."Business Entity SELECT-OPTIONS: s_bukrs FOR v_bukrs , s_swenr FOR v_swenr, s_rerf FOR v_rerf, s_derf FOR v_derf. SELECTION-SCREEN END OF BLOCK b1 . SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002."File Path PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-001."Business Entity PARAMETERS: p_varnt TYPE zdm_trans_var-varnt OBLIGATORY. SELECTION-SCREEN END OF BLOCK b3. *----------------------------------------------------------------------* C o n s t a n t s d e c l a r a t i o n s *----------------------------------------------------------------------CONSTANTS: c_tcode(6) TYPE c VALUE 'REBDBE', "Transaction Code c_g TYPE c VALUE 'G', "General c_1(3) TYPE c VALUE '001', "Constant for 001 Tab c_4(3) TYPE c VALUE '004', "Constant for 004 Tab c_5(3) TYPE c VALUE '005', "Constant for 005 Tab c_6(3) TYPE c VALUE '006', "Constant for 006 Tab c_7(3) TYPE c VALUE '007', "Constant for 007 Tab c_8(3) TYPE c VALUE '008', "Constant for 008 Tab c_9(3) TYPE c VALUE '009', "Constant for 009 Tab

c_10(3) c_15(3) c_bukrs(5) c_buk(3) c_swenr(5) c_ic(4) c_rebdbeno(8) c_rebdbe(6) c_varnt(5) c_pvarnt(7) c_rerfl(10) c_rerfh(11) c_rerf(4) c_zdmdrebdbe con_tab "Tab delimiter

TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE

c VALUE '010', "Constant for 010 Tab c VALUE '015', "Constant for 015 Tab c VALUE 'BUKRS', c VALUE 'BUK', c VALUE 'SWENR', c VALUE '&IC1', c VALUE 'REBDBENO', c VALUE 'REBDBE', c VALUE 'VARNT', c VALUE 'P_VARNT', c VALUE 'S_RERF-LOW', c VALUE 'S_RERF-HIGH', c VALUE 'RERF', tstc-tcode VALUE 'ZDMDREBDBE', c VALUE cl_abap_char_utilities=>horizontal_tab.

*----------------------------------------------------------------------* T y p e s *----------------------------------------------------------------------*Structure for preparing header of excel(Header1,Header2,Header3) TYPES: BEGIN OF t_header, fld TYPE char40, END OF t_header, *Displaying output ALV Strucutre BEGIN OF ty_output, bukrs TYPE bukrs, swenr TYPE rebdbeno, END OF ty_output, ty_line(5000) TYPE c, *entered by - Strucutre BEGIN OF ty_rerf, rerf TYPE rerf, END OF ty_rerf, *Type Structure for the Comments Table BEGIN OF ty_comment, catg TYPE z_catg, tab TYPE z_tab, scrfld TYPE z_scr, sequence TYPE z_sequence, rmark TYPE zremark, column(3) TYPE c, END OF ty_comment. *----------------------------------------------------------------------* I N T E R N A L T A B L E S *----------------------------------------------------------------------data :t_bus_entity type table of bapi_re_bus_entity, "Internal table for Business Entity t_seloption type table of bapi_re_seloption , "Internal table with headerline for Selection Options t_property type table of bapi_re_property , "Internal table with headerline for Land t_building type table of bapi_re_building , "Internal table with headerline for Buildings t_object_address type table of bapi_re_obj_address , "Internal table with headerline for Address of an RE Object

t_cosettle_param type table "Internal table with headerline for t_term_org_assignment type table "Internal table with headerline for t t_measurement "Internal table with t_partner "Internal table with t_option_rate "Internal table with t_cosettle_rule "Internal table with t_obj_assign "Internal table with t_arch_rel "Internal table with t_arch_relms "Internal table with t_resubm_rule "Internal table with t_resubm_date "Internal table with t_status "Internal table with t_extension_out "Internal table with xtensionOut w/ IDENT t_return "Internal table with t_infrastructure "Internal table with t_charact "Internal table with RE Object lt_comment " Internal Table for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for type table headerline for

of bapi_re_cosettle_par , CO Settlement Rule: Parameter of bapi_re_term_oa , Organizational Assignment of an RE Objec of bapi_re_measurement , Measurement of RE Object of bapi_re_partner , Partner of RE Object of bapi_re_option_rate , Option Rates for a Real Estate Object of bapi_re_cosettle_rl , CO Settlement Rule: Allocation Rules of bapi_re_obj_assign , Object Assignment of bapi_re_arch_rel , Architectural Linkage Objects of bapi_re_arch_relms , Architectural Linkage Object Parts of bapi_re_resubm_rule , Resubmission rule Date of RE Object of bapi_re_resubm_date , Resubmission Date of RE Object of bapi_re_status , Status for RE Objects of bapi_re_ident_parex , Reference Structure for BAPI Parameter E of bapiret2 , Return Parameter of bapi_re_infra , Infrastructure of an RE Object of bapi_re_charact , Fixtures and Fittings Characteristic of

TYPE STANDARD TABLE OF ty_comment. the Comments OF vibdbe, OF vitmoa, OF vibdmeas, OF vibpobjrel, OF viitoptrate, OF vibdobjass, OF vicarsrule, OF vibdinfra, OF cobrb, OF zdm_mapping, OF zdm_catg, OF zdm_tab, "Business En "Term: Organ "Measurement "Business Pa "Option Rate "Object Assi "Resubmissio "Infrastruct "Distributio "Mapping Tab "Category Ta "Tab Table

DATA: t_vibdbe TYPE STANDARD TABLE tity t_vitmoa TYPE STANDARD TABLE izational Assignment t_vibdmeas TYPE STANDARD TABLE t_vibpobjrel TYPE STANDARD TABLE rtner-Object Relationship t_viitoptrate TYPE STANDARD TABLE per Object and Period t_vibdobjass TYPE STANDARD TABLE gnment t_vicarsrule TYPE STANDARD TABLE n Rule for Object t_vibdinfra TYPE STANDARD TABLE ure t_cobrb TYPE STANDARD TABLE n Rules Settlement Rule Order Settlement t_mapping TYPE STANDARD TABLE le t_catg TYPE STANDARD TABLE ble t_tab TYPE STANDARD TABLE

t_tabt t_trans_var Field text t_output output lt_rerf t_head1 le-fieldname) t_head2 le"Tab: Texts t_head3 cription) t_edata t_fieldcat g for displyaing data it_fieldcat g for displaying t_rerf

TYPE STANDARD TABLE OF zdm_tabt, TYPE STANDARD TABLE OF zdm_trans_var, TYPE STANDARD TABLE OF ty_output, TYPE STANDARD TABLE OF ty_rerf, TYPE TABLE OF t_header , TYPE TYPE TYPE TYPE TYPE TABLE OF t_header, TABLE OF t_header,

"Tab: Texts "Transaction "Displaying "Entered by "Header1(tab "Header2(tab "Header3(Des

TABLE OF ty_line, "Excel table slis_t_fieldcat_alv, "Fieldcatalo lvc_t_fcat, "Fieldcatalo "Entered By

TYPE STANDARD TABLE OF ty_rerf.

DATA:w_seloption TYPE bapi_re_seloption. "Workarea for select options DATA: w_vibdbe TYPE vibdbe, "Business Entity w_vitmoa TYPE vitmoa, "Term: Organizational Assign ment w_vibdmeas TYPE vibdmeas, "Measurement w_vibpobjrel TYPE vibpobjrel, "Business Partner-Object Rel ationship w_viitoptrate TYPE viitoptrate, "Option Rate per Object and Period w_vibdobjass TYPE vibdobjass, "Object Assignment w_vicarsrule TYPE vicarsrule, "Resubmission Rule for Objec t w_vibdinfra TYPE vibdinfra, "Infrastructure w_cobrb TYPE cobrb, "Distribution Rules Settleme nt Rule Order Settlement w_tabt TYPE zdm_tabt, "Tab: Texts w_trans_var TYPE zdm_trans_var, "Transaction Field text w_head TYPE t_header, "Header wa_tab TYPE ty_line, "Excel table w_output TYPE ty_output, "Displaying output w_fieldcat TYPE slis_fieldcat_alv, "Fieldcatalog for displyaing data w_layout TYPE slis_layout_alv. "Layout for output display ** Excel OLE Objects DATA: w_excel TYPE Application w_workbook TYPE ook Application w_worksheet TYPE heet Application w_columns TYPE ns Application w_int TYPE alue w_range TYPE Application w_rc TYPE n value for Clip board w_sheets TYPE heet in excel ole2_object, ole2_object, ole2_object, ole2_object, ole2_object, ole2_object, i, ole2_object, " Excel " Workb " Works " Colom " Int V " Range " Retur " Works

w_newsheet eet of excel w_application cation of excel w_newbook rkbook of excel w_firstsheet sheet of excel

TYPE ole2_object, TYPE ole2_object, TYPE ole2_object, TYPE ole2_object.

" Newsh " Appli " Newwo " First

*----------------------------------------------------------------------* F I E L D S Y M B O LS *----------------------------------------------------------------------FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE, ic Internal Table <fs_wa> TYPE any, ic Workarea <fs_temp> TYPE any, ic Workarea <fs> TYPE any. ic Field *----------------------------------------------------------------------* V a r i a b l e d e c l a r a t i o n s *----------------------------------------------------------------------DATA: v_nsheet el sheets v_file le v_result download file v_varnt dyn_table nternal table dyn_line ntenal table v_tab v_catg v_excel v_sheetno et no TYPE i, TYPE string, TYPE abap_bool, TYPE zdm_trans_var-varnt, TYPE REF TO data, TYPE REF TO data, TYPE TYPE TYPE TYPE zdm_mapping-tab, zdm_mapping-catg, c, i.

"Dynam "Dynam "Dynam "Dynam

"No of exc "Output Fi "Result of "Variant "Dynamic I "Dynamic i "Tab "Category "Excel flag "Excel she

*********************************************************************** * L o a d - O f - P r o g r a m *********************************************************************** LOAD-OF-PROGRAM. *Authorization check CALL FUNCTION 'AUTHORITY_CHECK_TCODE' EXPORTING tcode = 'ZDMDREBDBE' " Program Tcode EXCEPTIONS ok = 1 not_ok = 2 OTHERS = 3. IF sy-subrc <> 1. MESSAGE e610(fr) WITH sy-uname. " Checking for Authorisation ENDIF. ************************************************************************ * A t s e l e c t i o n - s c r e e n ************************************************************************

*F4 help for the Field Created By SELECT DISTINCT rerf FROM vibdbe INTO TABLE t_rerf. *F4 help for variant AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt. PERFORM f4_help_varnt. * F4 help for the Field Created By AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_rerf-low. PERFORM f4_help_rerf_low. AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_rerf-high. PERFORM f4_help_rerf_high. *Validating the selection screen AT SELECTION-SCREEN. SELECT SINGLE * FROM vibdbe INTO w_vibdbe WHERE bukrs IN s_bukrs AND swenr IN s_swenr AND rerf IN s_rerf AND derf IN s_derf. IF sy-subrc NE 0. MESSAGE w398(00) WITH text-050 space space space."No data extracted for the given selection ELSE. CLEAR w_vibdbe. ENDIF. *validating the template entered in selection screen AT SELECTION-SCREEN ON p_varnt. SELECT SINGLE varnt FROM zdm_trans_var INTO v_varnt WHERE spras EQ sy-langu AND tcode = c_tcode AND varnt = p_varnt. IF sy-subrc NE 0. MESSAGE e398(00) WITH text-052 space space space."Please Enter the valid var iant ENDIF. *validating the output file wheathe it is exist or not AT SELECTION-SCREEN ON p_file. v_file = p_file. PERFORM validate_file IN PROGRAM zdm_global_routine USING v_file CHANGING v_re sult. IF v_result IS NOT INITIAL. MESSAGE w398(00) WITH text-051 space space space."File Exist ENDIF. *file path for downloading the output file AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. PERFORM file_path IN PROGRAM zdm_global_routine USING p_file. ************************************************************************ * S T A R T - O F - S E L E C T I O N ************************************************************************ START-OF-SELECTION. *data extraction PERFORM get_data.

IF t_vibdbe IS NOT INITIAL. *Master data PERFORM get_master_data IN PROGRAM zdm_global_routine TABLES t_tabt t_trans_var USING c_tcode p_varnt. **Data preperation PERFORM data_process. ENDIF. ************************************************************************ * E N D - O F - S E L E C T I O N ************************************************************************ END-OF-SELECTION. IF t_vibdbe IS NOT INITIAL. *Displyaing the output PERFORM data_display. ENDIF. *&---------------------------------------------------------------------* *& Form GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_data . **Business Entity * SELECT * FROM vibdbe INTO TABLE t_vibdbe * WHERE bukrs IN s_bukrs * AND swenr IN s_swenr * AND rerf IN s_rerf * AND derf IN s_derf. * * IF t_vibdbe IS NOT INITIAL. * **Term: Organizational Assignment * SELECT * FROM vitmoa INTO TABLE t_vitmoa * FOR ALL ENTRIES IN t_vibdbe * WHERE intreno = t_vibdbe-intreno. * **Measurement * SELECT * FROM vibdmeas INTO TABLE t_vibdmeas * FOR ALL ENTRIES IN t_vibdbe * WHERE intreno = t_vibdbe-intreno. * **Business Partner-Object Relationship * SELECT * FROM vibpobjrel INTO TABLE t_vibpobjrel * FOR ALL ENTRIES IN t_vibdbe * WHERE intreno = t_vibdbe-intreno. * **Resubmission Rule for Object * SELECT * FROM vicarsrule INTO TABLE t_vicarsrule * FOR ALL ENTRIES IN t_vibdbe * WHERE intreno = t_vibdbe-intreno. * **Infrastructure

* SELECT * FROM vibdinfra INTO TABLE t_vibdinfra * FOR ALL ENTRIES IN t_vibdbe * WHERE intreno = t_vibdbe-intreno. * **Option Rate per Object and Period * SELECT * FROM viitoptrate INTO TABLE t_viitoptrate * FOR ALL ENTRIES IN t_vibdbe * WHERE objnr = t_vibdbe-objnr. * **Object Assignment * SELECT * FROM vibdobjass INTO TABLE t_vibdobjass * FOR ALL ENTRIES IN t_vibdbe * WHERE objnrsrc = t_vibdbe-objnr. * **Distribution Rules Settlement Rule Order Settlement * SELECT * FROM cobrb INTO TABLE t_cobrb * FOR ALL ENTRIES IN t_vibdbe * WHERE objnr = t_vibdbe-objnr. * * ELSE. * * MESSAGE w398(00) WITH text-050 space space space. * * ENDIF. REFRESH : t_seloption. "Refreshing the select options table to populate data IF NOT s_bukrs[] IS INITIAL. e has data LOOP AT s_bukrs. code select options table w_seloption-field_name = 'COMP_CODE'. the select options workarea w_seloption-sign = s_bukrs-sign. select options workarea w_seloption-option = s_bukrs-option. e select options workarea w_seloption-field_value_low = s_bukrs-low. low value to the select options workarea w_seloption-field_value_high = s_bukrs-high. high value to the select options workarea APPEND w_seloption TO t_seloption. data to the select options table ENDLOOP. ENDIF. IF NOT s_swenr IS INITIAL. is has data LOOP AT s_swenr. ber select options table w_seloption-field_name select options workarea w_seloption-sign ct options workarea w_seloption-option e select options workarea w_seloption-field_value_low low value to select options workarea w_seloption-field_value_high "Check if company cod "Looping the company "Passing fieldname to "Passing sign to the "Passing option to th "Passing company code "Passing company code "Adding company code

"Check if site number "Looping the site num = 'BUSINESS_ENTITY'. "Passing fieldname to = s_swenr-sign. = s_swenr-option. = s_swenr-low. = s_swenr-high. "Passing sign to sele "Passing option to th "Passing site number "Passing site number

high value to select options workarea APPEND w_seloption TO t_seloption. ata to select options table ENDLOOP. ENDIF. * * *

"Adding site number d

CALL FUNCTION 'BAPI_RE_BE_GET_LIST' EXPORTING DETAIL_DATA_FROM = V_DFROM DETAIL_DATA_TO = V_DTO TABLES seloption = t_seloption bus_entity = t_bus_entity object_address = t_object_address cosettle_param = t_cosettle_param term_org_assignment = t_term_org_assignment measurement = t_measurement partner = t_partner option_rate = t_option_rate cosettle_rule = t_cosettle_rule obj_assign = t_obj_assign arch_rel = t_arch_rel arch_relms = t_arch_relms resubm_rule = t_resubm_rule resubm_date = t_resubm_date status = t_status extension_out = t_extension_out return = t_return infrastructure = t_infrastructure. ENDFORM. " GET_DATA *&---------------------------------------------------------------------* *& Form DATA_PROCESS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM data_process . *Preparing final internal table,Populating data and Downloading final internal t able to excel *----------------------------------------------------------------------DATA: lw_trans_var TYPE zdm_trans_var, "Loc al transvar workarea lt_var2 TYPE STANDARD TABLE OF zdm_trans_var, "Loc al internal table for trans var table to count no sheets in excel lv_column type i. "Lo cal variable for column value in comment table *Preparing data to local trans table lt_var2 = t_trans_var. *Sorting the local trans table based on sequence number SORT lt_var2 BY sequence. *Deleting the adjescent duplicates based on sequence number. DELETE ADJACENT DUPLICATES FROM lt_var2 COMPARING sequence. *To count number of sheets in excel DESCRIBE TABLE lt_var2 LINES v_nsheet.

*Reading the variant tabale based on sheet for sorting the internal table READ TABLE t_trans_var TRANSPORTING NO FIELDS WITH KEY sheet = 'S'. "Check it is single sheet IF sy-subrc EQ 0. *Sort variant table by field identity and sequence number in descending order SORT t_trans_var BY fidty DESCENDING tabfld sequence ASCENDING. ELSE. *sort the trans table by in sequence number ,field identity and table field in desending order. SORT t_trans_var DESCENDING BY sequence fidty tabfld. ENDIF. *********************************************** clear: lv_column. *********************************************** *Looping the trans table to download the data into the excel LOOP AT t_trans_var INTO lw_trans_var. v_catg = lw_trans_var-catg."Category v_tab = lw_trans_var-tab. "Tab * Preparing fieldcatalog for the Excel output table PERFORM fieldcat_intable IN PROGRAM zdm_global_routine TABLES t_head1 t_head2 t_head3 it_fieldcat lt_comment USING lw_trans_var sy-tabix. IF lw_trans_var-sheet = 'M'. AT END OF tab. "Triggers only at the end of the T ab No. * Getting the text from the tab text table based on the Spras,Catg,Tab READ TABLE t_tabt INTO w_tabt WITH KEY spras = sy-langu catg = v_catg tab = v_tab BINARY SEARCH. **Create dynamic table for the Field Catalog used for the ALV Grid Display PERFORM create_dynamic_table IN PROGRAM zdm_global_routine USING it_fieldcat CHANGING dyn_table. * Assigning Dyntable data to <fs_table> ASSIGN dyn_table->* TO <fs_table>. * Creating Dynamic line type with reference of dynamic internal table CREATE DATA dyn_line LIKE LINE OF <fs_table>. * Assigning Dynamic line type dynamci field symbol ASSIGN dyn_line->* TO <fs_wa>. * Populate data into internal table to download into Excel Sheets PERFORM data_populate. ENDAT. ELSE. AT END OF varnt. **Create dynamic table for the Field Catalog used for the ALV Grid Display PERFORM create_dynamic_table IN PROGRAM zdm_global_routine USING it_fieldcat

CHANGING dyn_table. * Assigning Dyntable data to <fs_table> ASSIGN dyn_table->* TO <fs_table>. * Creating Dynamic line type with reference of dynamic internal table CREATE DATA dyn_line LIKE LINE OF <fs_table>. * Assigning Dynamic line type dynamci field symbol ASSIGN dyn_line->* TO <fs_wa>. *populate the data into internal table to download into excel sheet PERFORM data_populate_single. ENDAT. ENDIF. ENDLOOP. * Check for excel sheet is initial or not IF v_excel EQ abap_true. * Save the Excel file after downloading the data into Multiple Excel sheets PERFORM save_excel IN PROGRAM zdm_global_routine USING w_excel w_workbook p_file. "Clearing the Work area to avoid data duplication / data replacements FREE OBJECT: w_worksheet, w_excel. ENDIF. ENDFORM. " DATA_PROCESS *&---------------------------------------------------------------------* *& Form DATA_POPULATE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM data_populate . IF v_catg EQ c_g. CASE v_tab. WHEN c_1. *populating business entity LOOP AT t_bus_entity ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>. WHEN c_4. *Term: Organizational Assignment LOOP AT t_term_org_assignment ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>.

WHEN c_5. *measurement data LOOP AT t_measurement ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>. WHEN c_6. *Business Partner-Object Relationship LOOP AT t_vibpobjrel INTO w_vibpobjrel. MOVE-CORRESPONDING w_vibpobjrel TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. WHEN c_7. *Option Rate per Object and Period LOOP AT t_option_rate ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>. WHEN c_8. *Distribution Rules Settlement Rule Order Settlement LOOP AT t_cobrb INTO w_cobrb. MOVE-CORRESPONDING w_cobrb TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. WHEN c_9. *Object Assignment LOOP AT t_obj_assign ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>.

WHEN c_10. *Resubmission Rule for Object LOOP AT t_resubm_rule ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. *Unassigning the dynamic workarea UNASSIGN <fs_temp>. WHEN c_15. *Infrastructure LOOP AT t_infrastructure ASSIGNING <fs_temp>. MOVE-CORRESPONDING <fs_temp> TO <fs_wa>. IF <fs_wa> IS NOT INITIAL. APPEND <fs_wa> TO <fs_table>. ENDIF. CLEAR <fs_wa>. ENDLOOP. ENDCASE. ENDIF. *Header1 CLEAR: wa_tab, w_head. LOOP AT t_head1 INTO w_head. ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. IF wa_tab IS INITIAL. wa_tab = <fs>. ELSE. CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDLOOP. APPEND wa_tab TO t_edata. **Header2 CLEAR: wa_tab, w_head. LOOP AT t_head2 INTO w_head. ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. IF wa_tab IS INITIAL. wa_tab = <fs>. ELSE. CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDLOOP. APPEND wa_tab TO t_edata. **Header3 CLEAR: wa_tab, w_head. LOOP AT t_head3 INTO w_head. ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. IF wa_tab IS INITIAL. wa_tab = <fs>. ELSE. CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF.

ENDLOOP. APPEND wa_tab TO t_edata. **Data DATA: lv_char TYPE char120. CLEAR: wa_tab, w_head. DELETE ADJACENT DUPLICATES FROM <fs_table> COMPARING ALL FIELDS. LOOP AT <fs_table> INTO <fs_wa>. DO. ASSIGN COMPONENT sy-index OF STRUCTURE <fs_wa> TO <fs>. IF sy-subrc NE 0. EXIT. ENDIF. lv_char = <fs>. IF wa_tab IS INITIAL. wa_tab = lv_char. ELSE. CONCATENATE wa_tab lv_char INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDDO. APPEND wa_tab TO t_edata. CLEAR wa_tab. ENDLOOP. IF gv_excel IS INITIAL. **Open excel sheet to populate data PERFORM open_excel IN PROGRAM zdm_global_routine USING v_nsheet w_workbook w _excel. gv_excel = abap_true. ENDIF. v_sheetno = v_sheetno + 1. * Excel Download PERFORM download_sheet IN PROGRAM zdm_global_routine TABLES t_edata t_head1 USING w_excel w_worksheet w_range w _columns w_int w_rc v_sheetno w_tabt-tab_text. GET PROPERTY OF w_excel 'ActiveSheet' = w_worksheet. REFRESH: it_fieldcat, t_head1, t_head2, t_head3, t_edata. ENDFORM. " DATA_POPULATE *&---------------------------------------------------------------------* *& Form DATA_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM data_display . *populating data into output internal table LOOP AT t_vibdbe INTO w_vibdbe. MOVE-CORRESPONDING w_vibdbe TO w_output. APPEND w_output TO t_output. CLEAR w_output. ENDLOOP. *preparing fieldcatalog PERFORM fieldcatalog. *displyaing the output table

IF t_output IS NOT INITIAL. w_layout-colwidth_optimize = abap_true. w_layout-zebra = abap_true. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND' it_fieldcat = t_fieldcat is_layout = w_layout TABLES t_outtab = t_output EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDIF. ENDFORM. " DATA_DISPLAY *&---------------------------------------------------------------------* *& Form USER_COMMAND *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->R_UCOMM text * -->RS_SELFIELD text *----------------------------------------------------------------------* FORM user_command USING r_ucomm LIKE sy-ucomm *Calling the transaction when clicks on company code rs_selfield TYPE slis_selfield. CASE r_ucomm. WHEN c_ic. CLEAR w_output. IF rs_selfield-fieldname EQ c_bukrs. SET PARAMETER ID c_buk FIELD rs_selfield-value. READ TABLE t_output INTO w_output INDEX rs_selfield-tabindex. IF sy-subrc EQ 0. SET PARAMETER ID c_rebdbeno FIELD w_output-swenr. ENDIF. CALL TRANSACTION c_rebdbe AND SKIP FIRST SCREEN. ENDIF. ENDCASE. ENDFORM. "USER_COMMAND *&---------------------------------------------------------------------* *& Form FIELDCATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM fieldcatalog . REFRESH t_fieldcat. PERFORM build_fieldcat USING c_bukrs text-003. "Company code PERFORM build_fieldcat USING c_swenr text-004. "Site Number ENDFORM. " FIELDCATALOG *&---------------------------------------------------------------------*

*& Form BUILD_FIELDCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_1568 text * -->P_TEXT_003 text *----------------------------------------------------------------------* FORM build_fieldcat USING p_fieldname p_text. *Preparing the fieldcatalog IF p_fieldname = c_bukrs. w_fieldcat-hotspot = abap_true. "Hotspot for company code ENDIF. w_fieldcat-fieldname = p_fieldname. w_fieldcat-seltext_m = p_text. APPEND w_fieldcat TO t_fieldcat. CLEAR w_fieldcat. ENDFORM. " BUILD_FIELDCAT *&---------------------------------------------------------------------* *& Form F4_HELP_VARNT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM f4_help_varnt . TYPES:BEGIN OF ty_varnt, varnt TYPE zvar, END OF ty_varnt. DATA:lt_trans_var TYPE STANDARD TABLE OF ty_varnt, lt_transt TYPE STANDARD TABLE OF zdm_trans_vart, lv_field TYPE help_info-dynprofld, lv_varnt TYPE dfies-fieldname. *Getting the variant data SELECT DISTINCT varnt FROM zdm_trans_var INTO TABLE lt_trans_var WHERE tcode = c_tcode. IF sy-subrc EQ 0. SELECT * FROM zdm_trans_vart INTO TABLE lt_transt FOR ALL ENTRIES IN lt_trans_var WHERE varnt = lt_trans_var-varnt AND spras = sy-langu. lv_field = c_pvarnt. lv_varnt = c_varnt. PERFORM f4_help TABLES lt_transt USING lv_varnt lv_field text-024. ENDIF. ENDFORM. " F4_HELP_VARNT *&---------------------------------------------------------------------* *& Form F4_HELP_RERF_LOW

*&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM f4_help_rerf_low . DATA:lv_rerfl TYPE help_info-dynprofld, lv_rerf TYPE dfies-fieldname. lv_rerf = c_rerf. lv_rerfl = c_rerfl. *F4 help for created by low field PERFORM f4_help TABLES t_rerf USING lv_rerf lv_rerfl text-025. ENDFORM. " F4_HELP_RERF_LOW *&---------------------------------------------------------------------* *& Form F4_HELP_RERF_HIGH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM f4_help_rerf_high . DATA:lv_rerfh TYPE help_info-dynprofld, lv_rerf TYPE dfies-fieldname. lv_rerf = c_rerf. lv_rerfh = c_rerfh. *F4 help for created by low field PERFORM f4_help TABLES t_rerf USING lv_rerf lv_rerfh text-025. ENDFORM. " F4_HELP_RERF_HIGH *&---------------------------------------------------------------------* *& Form F4_HELP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LT_TRANST text * -->P_LV_VARNT text * -->P_LV_FIELD text * -->P_TEXT_017 text *----------------------------------------------------------------------* FORM f4_help TABLES p_tab USING p_varnt p_pvarnt p_text. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = p_varnt dynpprog = sy-cprog dynpnr = sy-dynnr dynprofield = p_pvarnt window_title = p_text * VALUE = ' ' value_org = 'S' TABLES value_tab = p_tab

EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDFORM. " F4_HELP *&---------------------------------------------------------------------* *& Form DATA_POPULATE_SINGLE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form DATA_POPULATE_SINGLE . *Preparing the excel table for downloading PERFORM excel_data_preparation. endform. " DATA_POPULATE_SINGLE *&---------------------------------------------------------------------* *& Form EXCEL_DATA_PREPARATION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form EXCEL_DATA_PREPARATION . **Header1 table - having the Table-Field data on the first line of the Excel She et *--------------------------------------------------------------------*Clearing the Work area to avoid data duplication / data replacements CLEAR: wa_tab, w_head. * Looping the Header Data table "T_HEAD1" field to move the header data to the < fs> LOOP AT t_head1 INTO w_head. * Assigning the Header data workarea to <fs> ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. *Checking the tab workarea data is initial or not IF wa_tab IS INITIAL. wa_tab = <fs>. " moving the tab d ata to work area ELSE. *Concatenate the tab data Workarea and <fs> to Workarea CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDLOOP. *Adding the workarea data to Internal Table 't_edata'. APPEND wa_tab TO t_edata. **Header2 Table-having the Data type and length of the field on the Second line of the Excel Sheet *--------------------------------------------------------------------*Clearing the Work area to avoid data duplication / data replacements CLEAR: wa_tab, w_head.

* Looping the Header Data table "T_HEAD2" field to move the header data to the < fs> LOOP AT t_head2 INTO w_head. * Assigning the Header data workarea to <fs> ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. *Checking the tab workarea data is initial or not IF wa_tab IS INITIAL. wa_tab = <fs>. " moving the tab d ata to work area ELSE. *Concatenate the tab Workarea data and <fs> to Workarea CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDLOOP. *Adding the workarea data to Internal Line Table APPEND wa_tab TO t_edata. **Header3 table *--------------------------------------------------------------------*Clearing the Work area to avoid data duplication / data replacements CLEAR: wa_tab, w_head. * Looping the Header Data table "T_HEAD3" field to move the header data to the < fs> LOOP AT t_head3 INTO w_head. * Assigning the Header data workarea to <fs> ASSIGN COMPONENT sy-index OF STRUCTURE w_head TO <fs>. *Checking the tab workarea data is initial or not IF wa_tab IS INITIAL. wa_tab = <fs>. " moving the tab dat a to work area ELSE. *Concatenate the tab Workarea data and <fs> to Workarea CONCATENATE wa_tab <fs> INTO wa_tab SEPARATED BY con_tab. ENDIF. ENDLOOP. *Adding the tab data to Line table APPEND wa_tab TO t_edata. **Data table *--------------------------------------------------------------------DATA: lv_char TYPE char120. *Clearing the Work area to avoid data duplication / data replacements CLEAR: wa_tab, w_head. * Looping the <fs_table> table to move the data to the <fs> LOOP AT <fs_table> INTO <fs_wa>. DO. *Assigning the Structre of <fs_wa> to <fs> ASSIGN COMPONENT sy-index OF STRUCTURE <fs_wa> TO <fs>. * Checking that <fs> is having the structure of <fs_wa> IF sy-subrc NE 0. EXIT. " If the sy-subrc id failed then it Exit from the Loop ENDIF. lv_char = <fs>. IF wa_tab IS INITIAL. " Checking that the Tab workare is initail or not to upload the lv_char value into it wa_tab = lv_char. ELSE. *Concatenating the tab values of wa_tab and lv_char to wa_tab CONCATENATE wa_tab lv_char INTO wa_tab SEPARATED BY con_tab.

ENDIF. ENDDO. *Adding the tab data to Line table APPEND wa_tab TO t_edata. *Clearing the Work area to avoid data duplication / data replacements CLEAR wa_tab. ENDLOOP. * Checking for Excel is Initialised or not. IF v_excel IS INITIAL. **Open excel sheet to populate data PERFORM open_excel IN PROGRAM zdm_global_routine USING w_workbook w_application w_newbook w_excel. v_excel = 'X'. ENDIF. v_sheetno = v_sheetno + 1. " Increasing the Sheet n umber * Downloading the Sales Order Data into Excel Sheets PERFORM download_sheet IN PROGRAM zdm_global_routine TABLES t_edata t_head1 lt_comment USING w_excel w_newbook w_sheets w_newsheet w_application w_firstsheet w_range w_columns w_int w_rc v_sheetno w_tabt-tab_text. GET PROPERTY OF w_excel 'ActiveSheet' = w_worksheet. " Ge tting the Property of the Excel-WorkSheet REFRESH: it_fieldcat, t_head1, t_head2, t_head3, t_edata,lt_comment. " Refreshing the Internal tables for avoiding Dupliaction/ Data Replacing endform. " EXCEL_DATA_PREPARATION

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close