Abap Prgs - Sample
Abap Prgs - Sample
Abap Prgs - Sample
START-OF-SELECTION. PERFORM BUILD_IT_DATA. END-OF-SELECTION. PERFORM WRITE_REPORT. TOP-OF-PAGE. PERFORM TOP_OF_PAGE. TOP-OF-PAGE DURING LINE-SELECTION. PERFORM TOP_OF_PAGE. AT LINE-SELECTION. G_FIELD = SPACE. GET CURSOR FIELD G_FIELD. PERFORM LINE_SELECTION. AT USER-COMMAND. G_FIELD = SPACE. GET CURSOR FIELD G_FIELD. PERFORM USER_COMMAND. *---------------------------------------------------------------------* * FORM BUILD_IT_DATA * *---------------------------------------------------------------------* FORM BUILD_IT_DATA. IT_DATA-WERKS = '0000'. WHILE IT_DATA-WERKS < '0100'. ADD '10' TO IT_DATA-WERKS. W_MATNR = 0. WHILE W_MATNR < 10. ADD 1 TO W_MATNR. IT_DATA-EXP = '+'. WRITE W_MATNR TO IT_DATA-MATNR. IF IT_DATA-WERKS = 10 AND W_MATNR = 1. WRITE 'ZTEST2' TO IT_DATA-VALUE1. WRITE 'Testing program 2' TO IT_DATA-VALUE2. ELSE. CLEAR: IT_DATA-VALUE1, IT_DATA-VALUE2. ENDIF. APPEND IT_DATA. ENDWHILE. ENDWHILE. ENDFORM. *---------------------------------------------------------------------* * FORM WRITE_REPORT * *---------------------------------------------------------------------* FORM WRITE_REPORT. SET PF-STATUS '8000'. SYST-LSIND = '0'. LOOP AT IT_DATA. AT NEW WERKS. FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE: /1 SYST-VLINE NO-GAP, '[' NO-GAP, IT_DATA-EXP NO-GAP HOTSPOT ON, ']'.
FORMAT COLOR COL_NORMAL INTENSIFIED ON. WRITE: IT_DATA-WERKS, AT SYST-LINSZ SYST-VLINE. PAGE-PAGNO = SYST-PAGNO. HIDE: IT_DATA-WERKS, PAGE-PAGNO. ENDAT. IF IT_DATA-EXP = '-'. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WRITE: /1 SYST-VLINE, 8 IT_DATA-MATNR, IT_DATA-VALUE1 INPUT ON, IT_DATA-VALUE2 INPUT ON, AT SYST-LINSZ SYST-VLINE. HIDE: IT_DATA, PAGE-PAGNO. ENDIF. ENDLOOP. ULINE. ENDFORM. *---------------------------------------------------------------------* * FORM USER_COMMAND * *---------------------------------------------------------------------* FORM USER_COMMAND. PERFORM SET_SCROLL_LINE. CASE SY-UCOMM. WHEN 'ENTE'. READ TABLE IT_DATA WITH KEY WERKS = IT_DATA-WERKS MATNR = IT_DATA-MATNR. IF SYST-SUBRC = 0. CASE G_FIELD. WHEN 'IT_DATA-VALUE1'. IF IT_DATA-VALUE1 <> SPACE. SUBMIT (IT_DATA-VALUE1) VIA SELECTION-SCREEN AND RETURN. ELSE. IT_DATA-VALUE1 = 'Enter 1 Press'(001). ENDIF. WHEN 'IT_DATA-VALUE2'. IT_DATA-VALUE2 = 'Enter 2 Press'(001). ENDCASE. MODIFY IT_DATA INDEX SYST-TABIX. ENDIF. PERFORM WRITE_REPORT. PERFORM POSITION_LIST. CASE G_FIELD. WHEN 'IT_DATA-EXP'. ADD 1 TO PAGE-CURSLINE. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE1'. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE2'. SET CURSOR FIELD 'IT_DATA-VALUE2' LINE PAGE-CURSLINE. ENDCASE. WHEN 'EXPA'. PERFORM SET_EXPAND USING '-'. PERFORM WRITE_REPORT. WHEN 'COLA'. PERFORM SET_EXPAND USING '+'. PERFORM WRITE_REPORT.
ENDCASE. ENDFORM. *---------------------------------------------------------------------* * FORM SET_EXPAND * *---------------------------------------------------------------------* FORM SET_EXPAND USING W_EXP. LOOP AT IT_DATA. IT_DATA-EXP = W_EXP. MODIFY IT_DATA INDEX SYST-TABIX. ENDLOOP. ENDFORM. *---------------------------------------------------------------------* * FORM LINE_SELECTION * *---------------------------------------------------------------------* FORM LINE_SELECTION. PERFORM SET_SCROLL_LINE. READ TABLE IT_DATA WITH KEY WERKS = IT_DATA-WERKS MATNR = IT_DATA-MATNR. CASE G_FIELD. WHEN 'IT_DATA-EXP'. LOOP AT IT_DATA WHERE WERKS = IT_DATA-WERKS. IF IT_DATA-EXP = '-'. IT_DATA-EXP = '+'. ELSE. IT_DATA-EXP = '-'. ENDIF. MODIFY IT_DATA INDEX SYST-TABIX. ENDLOOP. WHEN 'IT_DATA-VALUE1'. IT_DATA-VALUE1 = 'Double Click'(004). MODIFY IT_DATA INDEX SYST-TABIX. WHEN 'IT_DATA-VALUE2'. IT_DATA-VALUE2 = 'Double Click'(004). MODIFY IT_DATA INDEX SYST-TABIX. ENDCASE. PERFORM WRITE_REPORT. PERFORM POSITION_LIST. CASE G_FIELD. WHEN 'IT_DATA-EXP'. ADD 1 TO PAGE-CURSLINE. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE1'. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE2'. SET CURSOR FIELD 'IT_DATA-VALUE2' LINE PAGE-CURSLINE. ENDCASE. ENDFORM. *---------------------------------------------------------------------* * FORM SET_SCROLL_LINE * * determine the correct line to scroll the re-written report to, so * * that the user is returned to the same spot on the screen * * if user is mid way between pages, ie two headers are visable on the * * screen, check if they are on the secondary page and adjust the * * scroll variable accordingly so as not to jump up lines because the * * scroll variable will be out by the number of lines in the extra hdr * *---------------------------------------------------------------------* FORM SET_SCROLL_LINE.
PAGE-CURSLINE = SYST-LILLI. PAGE-SCRLLINE = SYST-LILLI - ( SYST-CUROW - PAGE-HDRLINES ). PAGE-PGELINES = ( PAGE-PAGNO - 1 ) * SYST-LINCT. PAGE-CPOSTOP = ( PAGE-SCRLLINE + SYST-CUROW ) - PAGE-PGELINES. PAGE-CPOSBOT = ( PAGE-SCRLLINE - SYST-CUROW ) - PAGE-PGELINES. PAGE-CPOSIT = PAGE-CPOSTOP + PAGE-CPOSBOT. PAGE-TWOHDRS = PAGE-HDRLINES * 2. IF PAGE-CPOSIT LT PAGE-TWOHDRS. PAGE-SCRLLINE = PAGE-SCRLLINE + 1. ENDIF. ENDFORM. *---------------------------------------------------------------------* * FORM POSITION_LIST * *---------------------------------------------------------------------* FORM POSITION_LIST. CALL FUNCTION 'LIST_SCROLL_LINE_TOPMOST' EXPORTING LIST_INDEX = 1 LIST_LINE = PAGE-SCRLLINE EXCEPTIONS OTHERS = 1. CHECK SYST-SUBRC = 0. ENDFORM. *---------------------------------------------------------------------* * FORM TOP_OF_PAGE * *---------------------------------------------------------------------* FORM TOP_OF_PAGE. * set page-hdrlines = lines in header + 1 system generated blank line PAGE-HDRLINES = 5. ULINE. WRITE : /1 SYST-VLINE, 'Header'(002), AT SYST-LINSZ SYST-VLINE. WRITE : /1 SYST-VLINE, 'Lines'(003), AT SYST-LINSZ SYST-VLINE. ULINE. ENDFORM.
Steps :1. Number range Sub Object must be maintain in table ZSGRP You can used transaction SE16 to create a table entries. 2. Maintain number range and intervals in transaction code SNUM Written by : SAP Basis, ABAP Programming and Other IMG Stuff http://www.sap-img.com
call function 'NUMBER_RANGE_ENQUEUE' exporting object = 'ZOWNNO' exceptions foreign_lock = 1 object_not_found = 2 system_failure = 3 others = 4. if sy-subrc ne 0. * message e086 with 'Lock error' sy-subrc. endif. call function 'NUMBER_GET_NEXT' exporting nr_range_nr = wnorange object = 'ZOWNNO' subobject = wsubobj importing number = wdocno exceptions interval_not_found = 1 number_range_not_intern = 2 object_not_found = 3 quantity_is_0 = 4 quantity_is_not_1 = 5 internal_overflow = 6 others = 7. if sy-subrc ne 0. * message e086 with 'Number Range' sy-subrc. endif. call function 'NUMBER_RANGE_DEQUEUE' exporting
object
= 'ZOWNNO'.
if sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif.
Content Author: RAKESH SINGH SAP Programer Analyst I need a code for calling any html page into SAP report Or linking sap R/3 with html file. Used this function module: CALL FUNCTION 'GUI_RUN' EXPORTING command ='IEXPLORE.EXE' PARAMETER ='WWW.YAHOOMAIL.COM'. * CD = * IMPORTING * RETURNCODE =
SCREEN-INPUT = 0. MODIFY SCREEN. ENDLOOP. ENDIF. * For example, if the user enter the Modify Screen, you will make all the Fields Group 1 that * have a 'M' non-Editable. * You specify the 'M' for Group 1 using the Screen Painter Attribute IF OKSAVE = 'MOD'. * Make the DELE Menu button inactive SET PF-STATUS 'Z250' EXCLUDING 'DELE'. * Make all the Fields Groups 'M' non-Editable LOOP AT SCREEN. check screen-group1 = 'M'. SCREEN-INPUT = 0. MODIFY SCREEN. ENDLOOP. ENDIF. CLEAR OKCODE. ENDMODULE.
-----Reply Message----Subject: RE: Scrolling in Table Control From amit.purohit That worked. Thank you for prompt reply. Amit.
DATA timer TYPE REF TO cl_gui_timer. DATA event_handler TYPE REF TO lcl_event_handler. DATA timeout TYPE i VALUE '3'. *&---------------------------------------------------------------------* * SELECTION-SCREEN DESIGN * *&---------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK b2sels WITH FRAME TITLE text-002. PARAMETERS: pwerks LIKE mseg-werks OBLIGATORY, "THIS Plant pbudat LIKE mkpf-budat OBLIGATORY. "THIS Date SELECTION-SCREEN: END OF BLOCK b2sels. *&---------------------------------------------------------------------* * INITIALIZATION EVENT * *&---------------------------------------------------------------------* INITIALIZATION. *&---------------------------------------------------------------------* * AT SELECTION-SCREEN EVENT * *&---------------------------------------------------------------------* **Use this EVENT to validate SELECTION-SCREEN AT SELECTION-SCREEN. *&---------------------------------------------------------------------* * START-OF-SELECTION EVENT * *&---------------------------------------------------------------------* START-OF-SELECTION. CALL SCREEN 0806 STARTING AT 30 4. *&---------------------------------------------------------------------* *& Form f_excel_job *&---------------------------------------------------------------------* FORM f_excel_job. * LOTS of Code CALL SCREEN 2009 STARTING AT 30 4. ENDFORM. ** LOTS of CODE *&---------------------------------------------------------------------* *& Form getpicurl *&---------------------------------------------------------------------* FORM getpicurl. OPEN DATASET g_name FOR INPUT IN BINARY MODE. REFRESH graphic_table. "f_excel_job
CLEAR
g_filesz.
DO. CLEAR graphic_line. READ DATASET g_name INTO graphic_line ACTUAL LENGTH g_linesz. ADD g_linesz TO g_filesz. APPEND graphic_line TO graphic_table. IF sy-subrc <> 0. EXIT. ENDIF. ENDDO. CLOSE DATASET g_name. CLEAR graphic_url. CALL FUNCTION 'DP_CREATE_URL' EXPORTING type = 'IMAGE' subtype = 'GIF' TABLES data = graphic_table CHANGING url = graphic_url EXCEPTIONS dp_invalid_parameter = 1 dp_error_put_table = 2 dp_error_general = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. EXIT. ENDIF. IF graphic_url IS NOT INITIAL. CALL METHOD picture->clear_picture EXCEPTIONS error = 1. CALL METHOD picture->load_picture_from_url EXPORTING url = graphic_url IMPORTING RESULT = g_result. CALL METHOD picture->set_display_mode EXPORTING display_mode = picture->display_mode_normal_center EXCEPTIONS
error
= 1.
*---------------------------------------------------------------------* * MODULE zjncpbo OUTPUT screen 0806 *---------------------------------------------------------------------* MODULE zjncpbo OUTPUT. MOVE 'NAMASTE.JPG' TO g_name. CREATE OBJECT: container1 container2 picture timer EXPORTING EXPORTING EXPORTING EXPORTING container_name = 'CUSTOM_1', container_name = 'CUSTOM_2', parent = container1, parent = container2.
SET HANDLER lcl_event_handler=>on_finished FOR timer. * Start Timer timer->interval = timeout. CALL METHOD timer->run. PERFORM getpicurl. CALL METHOD cl_gui_cfw=>flush. ENDMODULE. " PBO
*---------------------------------------------------------------------* * MODULE zjncpbo2 OUTPUT screen 2009 *---------------------------------------------------------------------* MODULE zjncpbo2 OUTPUT. MOVE 'THANKS.JPG' TO g_name. CREATE OBJECT: container1 container2 picture timer EXPORTING EXPORTING EXPORTING EXPORTING container_name = 'CUSTOM_1', container_name = 'CUSTOM_2', parent = container1, parent = container2.
SET HANDLER lcl_event_handler=>on_finished FOR timer. * Start Timer timer->interval = timeout. CALL METHOD timer->run. PERFORM getpicurl. CALL METHOD cl_gui_cfw=>flush. ENDMODULE.
ENDFORM.
ENDSELECT. if lt_modname is INITIAL. WRITE / 'no active enhancements'. endif. * Determine the details about the customer enhancement. LOOP AT lt_modname INTO ls_modname. CLEAR : ls_display. SELECT member from modact into ls_member where name = ls_modname. select member from modsap into ls_fm where name = ls_member and typ = 'E'. ls_display-project = ls_modname. ls_display-enhancement = ls_member. ls_display-fm = ls_fm. clear : ls_function. ls_function-fname = ls_fm. perform get_impl_status USING ls_function. if ls_function-impl = 'X'. ls_display-status = 'Implemented'. ELSE. ls_display-status = 'Active'. endif. APPEND ls_display to lt_display. endselect. ENDSELECT. ENDLOOP. * Displaying results format color = 1. write : 'Please double-click on the object for follow-on action'. new-LINE. uline. write : 'Customer Project', at 30 'SAP Enhancement', at 60 'Exit Function Modul e', at 100 'Active/Implemented'. ULINE. format color = 0. loop at lt_display into ls_display. new-LINE. write : ls_display-project, at 30 ls_display-enhancement, at 60 ls_displayfm, at 100 ls_display-status. ENDLOOP. * For calling transaction CMOD / SMOD / SE37. at line-selection. get cursor field field1. CASE field1. WHEN 'LS_DISPLAY-PROJECT'. set parameter id 'MON_KUN' field sy-lisel(10). call transaction 'CMOD' and skip first screen. WHEN 'LS_DISPLAY-ENHANCEMENT'. set parameter id 'MON' field sy-lisel+29(10). call transaction 'SMOD' and skip first screen. WHEN 'LS_DISPLAY-FM'. set parameter id 'LIB' field sy-lisel+59(30). call transaction 'SE37' and skip first screen. WHEN OTHERS. message 'Click on the right place.' TYPE 'I'. ENDCASE. *&---------------------------------------------------------------------*
*& Form get_impl_status *&---------------------------------------------------------------------* * This FORM checks whether an EXIT FM is implemented or not *----------------------------------------------------------------------* form get_impl_status using p_function type s_function. data : l_mand LIKE tfdir-mand, l_incl_names TYPE smod_names OCCURS 1 WITH HEADER LINE. l_incl_names-itype = 'C'. APPEND l_incl_names. CLEAR l_mand. SELECT SINGLE mand FROM tfdir INTO l_mand WHERE funcname = p_function-fname. IF sy-subrc = 0 AND l_mand(1) = 'C'. p_function-active = 'X'. * l_status-active = c_true. ELSE. p_function-active = ' '. * l_status-inactive = c_true. ENDIF. CALL FUNCTION 'MOD_FUNCTION_INCLUDE' EXPORTING funcname = p_function-fname TABLES incl_names = l_incl_names EXCEPTIONS OTHERS = 4. IF sy-subrc = 0. LOOP AT l_incl_names. SELECT SINGLE name FROM trdir INTO l_incl_names-iname WHERE name = l_incl_names-iname. IF sy-subrc = 0. p_function-impl = 'X'. ELSE. p_function-impl = ' '. ENDIF. ENDLOOP. ENDIF. endform.
SELECTION-SCREEN END OF BLOCK B2. * Sort criteria input SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE T6. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) T1. SELECTION-SCREEN POSITION 62. PARAMETERS: A1 RADIOBUTTON GROUP SORT. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(55) T2. SELECTION-SCREEN POSITION 62. PARAMETERS: A2 RADIOBUTTON GROUP SORT. PARAMETERS: A3 RADIOBUTTON GROUP SORT. SELECTION-SCREEN POSITION 67. PARAMETERS: A4 RADIOBUTTON GROUP SORT. PARAMETERS: A5 RADIOBUTTON GROUP SORT. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(55) T3. SELECTION-SCREEN POSITION 62. PARAMETERS: A6 RADIOBUTTON GROUP SORT. PARAMETERS: A7 RADIOBUTTON GROUP SORT. SELECTION-SCREEN POSITION 67. PARAMETERS: A8 RADIOBUTTON GROUP SORT. PARAMETERS: A9 RADIOBUTTON GROUP SORT. SELECTION-SCREEN POSITION 72. PARAMETERS: AA RADIOBUTTON GROUP SORT. PARAMETERS: AB RADIOBUTTON GROUP SORT. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(50) T4. SELECTION-SCREEN POSITION 62. PARAMETERS: AC RADIOBUTTON GROUP SORT. PARAMETERS: AD RADIOBUTTON GROUP SORT. SELECTION-SCREEN POSITION 67. PARAMETERS: AE RADIOBUTTON GROUP SORT. PARAMETERS: AF RADIOBUTTON GROUP SORT. SELECTION-SCREEN POSITION 72. PARAMETERS: AG RADIOBUTTON GROUP SORT. PARAMETERS: AH RADIOBUTTON GROUP SORT. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK B3. *Internal tables DATA: BEGIN OF V1_NORMAL_RECORDS OCCURS 100. INCLUDE STRUCTURE SAPWLSTATR. DATA: END OF V1_NORMAL_RECORDS. DATA: BEGIN OF V2_NORMAL_RECORDS OCCURS 100. INCLUDE STRUCTURE SAPWLPFNRM. DATA: END OF V2_NORMAL_RECORDS. DATA: BEGIN OF SUM OCCURS 100, ACCOUNT(32), READSEQREC TYPE I, READSEQTI TYPE I, READDIRREC TYPE I,
READDIRTI TYPE I, UPDREC TYPE I, UPDTI TYPE I, DELREC TYPE I, DELTI TYPE I, INSREC TYPE I, INSTI TYPE I, SUM_RD_ROW TYPE I, SUM_RD_TIM TYPE I, SUM_MOD_ROW TYPE I, SUM_MOD_TIM TYPE I, SUM_ALL_ROW TYPE I, SUM_ALL_TIM TYPE I, END OF SUM. *Initialize the selection screen INITIALIZATION. T1 = 'User Name and Report Name'. T2 = 'READ: Sequential(row/time) Direct(row/time)'. T3 = 'Update(row/time) Delete(row/time) Insert(row/time)'. T4 = 'SUM: Read(row/time) Modify(row/time) All(row/time)'. T5 = 'Sort'. T6 = 'By'. T7 = 'Period, Client and STAT file'. F1 F2 * F3 F4 F5 = = = = = 'From: (date/time)'. 'To: (date/time)'. 'STAT file path(only for old stat)'. 'Client'. 'Ascending/Descending'.
FDAT = SY-DATUM. FTIM = SY-UZEIT. FDAT = FDAT - 1. TTIM = SY-UZEIT. TDAT = SY-DATUM. CLI = SY-MANDT. * Write a page header TOP-OF-PAGE. WRITE: / 'User and Report ' COLOR 2, 34(15) 'Sequential read' COLOR 2, 50(15) 'Direct read' COLOR 2, 66(15) 'Update' COLOR 2, 82(15) 'Delete' COLOR 2, 98(15) 'Insert' COLOR 2, 114(15) 'Sum Read' COLOR 5, 130(15) 'Sum Modify' COLOR 5, 146(15) 'Sum All' COLOR 6. WRITE: / 34(6) 41(8) 50(6) 57(8) 66(6) 73(8) 82(6) 89(8) 'name' COLOR 2, 'rows' COLOR 2, 'time(ms)' COLOR 'rows' COLOR 2, 'time(ms)' COLOR 'rows' COLOR 2, 'time(ms)' COLOR 'rows' COLOR 2, 'time(ms)' COLOR
2, 2, 2, 2,
'rows' COLOR 2, 'time(ms)' COLOR 'rows' COLOR 5, 'time(ms)' COLOR 'rows' COLOR 5, 'time(ms)' COLOR 'rows' COLOR 6, 'time(ms)' COLOR
2, 5, 5, 6.
* Main START-OF-SELECTION. * Figure out the sort field name IF A1 = 'X'. SORT_FIELD = 'ACCOUNT'. ELSEIF A2 = 'X'. SORT_FIELD = 'READSEQREC'. ELSEIF A3 = 'X'. SORT_FIELD = 'READSEQTI'. ELSEIF A4 = 'X'. SORT_FIELD = 'READDIRREC'. ELSEIF A5 = 'X'. SORT_FIELD = 'READDIRTI'. ELSEIF A6 = 'X'. SORT_FIELD = 'UPDREC'. ELSEIF A7 = 'X'. SORT_FIELD = 'UPDTI'. ELSEIF A8 = 'X'. SORT_FIELD = 'DELREC'. ELSEIF A9 = 'X'. SORT_FIELD = 'DELTI'. ELSEIF AA = 'X'. SORT_FIELD = 'INSREC'. ELSEIF AB = 'X'. SORT_FIELD = 'INSTI'. ELSEIF AC = 'X'. SORT_FIELD = 'SUM_RD_ROW'. ELSEIF AD = 'X'. SORT_FIELD = 'SUM_RD_TIM'. ELSEIF AE = 'X'. SORT_FIELD = 'SUM_MOD_ROW'. ELSEIF AF = 'X'. SORT_FIELD = 'SUM_MOD_TIM'. ELSEIF AG = 'X'. SORT_FIELD = 'SUM_ALL_ROW'. ELSEIF AH = 'X'. SORT_FIELD = 'SUM_ALL_TIM'. ENDIF. CALL FUNCTION 'SAPWL_STATREC_READ_FILE' EXPORTING READ_CLIENT = CLI READ_END_DATE = TDAT READ_END_TIME = TTIM READ_START_DATE = FDAT READ_START_TIME = FTIM * STATISTIC_FILE = FILE IMPORTING
STATISTIC_VERSION_USED = STATISTIC_VERSION_USED TABLES V1_NORMAL_RECORDS = V1_NORMAL_RECORDS V2_NORMAL_RECORDS = V2_NORMAL_RECORDS. LOOP AT V2_NORMAL_RECORDS. V2_NORMAL_RECORDS-READSEQTI = V2_NORMAL_RECORDS-READSEQTI / 1000. V2_NORMAL_RECORDS-READDIRTI = V2_NORMAL_RECORDS-READDIRTI / 1000. V2_NORMAL_RECORDS-UPDTI = V2_NORMAL_RECORDS-UPDTI / 1000. V2_NORMAL_RECORDS-DELTI = V2_NORMAL_RECORDS-DELTI / 1000. V2_NORMAL_RECORDS-INSTI = V2_NORMAL_RECORDS-INSTI / 1000. MODIFY V2_NORMAL_RECORDS. ENDLOOP. LOOP AT V1_NORMAL_RECORDS. V1_NORMAL_RECORDS-READSEQTI = V1_NORMAL_RECORDS-READSEQTI / 1000. V1_NORMAL_RECORDS-READDIRTI = V1_NORMAL_RECORDS-READDIRTI / 1000. V1_NORMAL_RECORDS-UPDTI = V1_NORMAL_RECORDS-UPDTI / 1000. V1_NORMAL_RECORDS-DELTI = V1_NORMAL_RECORDS-DELTI / 1000. V1_NORMAL_RECORDS-INSTI = V1_NORMAL_RECORDS-INSTI / 1000. MODIFY V1_NORMAL_RECORDS. ENDLOOP. LOOP AT V2_NORMAL_RECORDS. MOVE-CORRESPONDING V2_NORMAL_RECORDS TO SUM. CONCATENATE V2_NORMAL_RECORDS-ACCOUNT V2_NORMAL_RECORDS-CUA_PROG INTO SUM-ACCOUNT SEPARATED BY SPACE. COLLECT SUM. ENDLOOP. LOOP AT V1_NORMAL_RECORDS. MOVE-CORRESPONDING V1_NORMAL_RECORDS TO SUM. CONCATENATE V1_NORMAL_RECORDS-ACCOUNT V1_NORMAL_RECORDS-CUA_PROG INTO SUM-ACCOUNT SEPARATED BY SPACE. COLLECT SUM. ENDLOOP. LOOP AT SUM. SUM-SUM_RD_ROW SUM-SUM_RD_TIM SUM-SUM_MOD_ROW SUM-SUM_MOD_TIM SUM-SUM_ALL_ROW SUM-SUM_ALL_TIM MODIFY SUM. ENDLOOP. = = = = = = SUM-READSEQREC + SUM-READDIRREC. SUM-READSEQTI + SUM-READDIRTI. SUM-UPDREC + SUM-DELREC + SUM-INSREC. SUM-UPDTI + SUM-DELTI + SUM-INSTI. SUM-SUM_RD_ROW + SUM-SUM_MOD_ROW. SUM-SUM_RD_TIM + SUM-SUM_MOD_TIM.
IF ASC = 'X'. SORT SUM BY (SORT_FIELD) ASCENDING. ELSE. SORT SUM BY (SORT_FIELD) DESCENDING. ENDIF. LOOP AT SUM. WRITE: / SUM-ACCOUNT, 34(7) SUM-READSEQREC,
42(7) 54(7) 58(7) 66(7) 74(7) 82(7) 90(7) 98(7) 106(7) 114(7) 122(7) 130(7) 138(7) 146(7) 154(7)
SUM-READSEQTI, SUM-READDIRREC, SUM-READDIRTI, SUM-UPDREC, SUM-UPDTI, SUM-DELREC, SUM-DELTI, SUM-INSREC, SUM-INSTI, SUM-SUM_RD_ROW, SUM-SUM_RD_TIM, SUM-SUM_MOD_ROW, SUM-SUM_MOD_TIM, SUM-SUM_ALL_ROW, SUM-SUM_ALL_TIM.
REPORT ZREP2 NO STANDARD PAGE HEADING. tables: qals. RANGES seltab for qals-prueflos. WRITE: 'Select a Selection!', / '--------------------'. SKIP. FORMAT HOTSPOT COLOR 5 INVERSE ON. WRITE: 'Selection 1', / 'Selection 2'. AT LINE-SELECTION. CASE SY-LILLI.
WHEN 4. SUBMIT zrep1 VIA SELECTION-SCREEN WITH PARAMET EQ 'Selection 1' WITH SELECTO IN SELTAB WITH SELECTO NE 3 AND RETURN. WHEN 5.
SUBMIT zrep1 VIA SELECTION-SCREEN WITH PARAMET EQ 'Selection 1' AND RETURN. ENDCASE.
How to edit entries of table in se11 ? To update the data of any table, go to transaction SE16N, type &SAP_EDIT. It will activate SAP editing function. --Go to table and press Ctrl+ shift + F10 where you will go to table entries. Click on F8 (execute). And then select the entries that you want to edit by selecting the checkbox and goto menu Table entry - > select change. There you edit and save the entries. --You cannot edit entries in SE11 unless it contains a Table maintenance generator. So just build a Table maintenance generator. Do not delete any entries using &SAP_EDIT...it is not recommended. --You can edit through debugging.
How to delete a record in SE16 ? To delete the records from particular table its easy. Goto : se11 - Give the table name - Execute the table with the selection fields - Then data (list) screen will be displayed. - Now select the record which has to be deleted - Select that and switch 'on' the Debugging mode press enter - Then press F6 goes to subroutine where there is field called display - Instead change it to edit and then save the changes then it will take you to the screen where you can edit that records & also delete that particular records.
Note: After displaying the contents of the list. Switch ON the Debug Mode the select the particular record then click display then it will take u to Debug Screen when there is a program for sy-ucomm then click F7 Button and then Change Code = EDIT then save the code the afterwards it will take u to edit mode of that particular record.
How can I insert new data in the table? Give the transaction code as se11 In that give the table name and press display Then in that field name above there is delivery and maintenance click the same and change it as display maintenance allowed.
How to write abap codes to delete from Z table? Try with FM SE16N_INTERFACE I_TAB = Name of the table(MARA) I_EDIT = 'X' I_SAPEDIT = 'X' Tables IT_SELFIELDS pass the value of the fields in table and then append that to IT_SELFIELDS Field MATNR SI OP EQ LOW value or you can use delete db from table itab. Here itab should be a internal table and contain the data to be deleted. or delete from db where condition.
update db from table itab. Check this program its for update and delete the records from a table *&---------------------------------------------------------------------* *& Report ZTEST6 * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZTEST6 NO STANDARD PAGE HEADING MESSAGE-ID SAPLWOSA.
*======================================================================= * Variables *======================================================================= DATA DESCR_STRUCT_REF TYPE REF TO CL_ABAP_STRUCTDESCR. DATA WA_FCAT TYPE LVC_S_FCAT. DATA IT_FIELDCATALOG TYPE LVC_T_FCAT. DATA DATAREF TYPE REF TO DATA. DATA: ONE LIKE PCFILE-DRIVE, TWO LIKE PCFILE-PATH, LONG TYPE I, FLAG TYPE C, FILEPATH(128) TYPE C, FILE_TAB TYPE STRING, TABNAME LIKE DD02L-TABNAME. *======================================================================= * Field-Symbols. *======================================================================= FIELD-SYMBOLS: <ROW> TYPE ANY TABLE, <TABLE> TYPE STANDARD TABLE, <COMPONENT> TYPE ABAP_COMPDESCR, <FS> TYPE ANY. *======================================================================= * Selection screen *======================================================================= SELECTION-SCREEN BEGIN OF BLOCK DATA WITH FRAME TITLE TEXT-T01. PARAMETERS: TABNAM(128) TYPE C, FUNCTION(1) TYPE C OBLIGATORY,
LISTNAME LIKE RLGRAP-FILENAME. SELECTION-SCREEN END OF BLOCK DATA. *======================================================================= * At Selection screen *======================================================================= AT SELECTION-SCREEN ON VALUE-REQUEST FOR LISTNAME. PERFORM GET_FILENAME CHANGING LISTNAME. *======================================================================= * Start-of-selection *======================================================================= START-OF-SELECTION. CLEAR FLAG. PERFORM LOAD_DATA USING TABNAM. PERFORM VERIFY_TABLE USING TABNAM CHANGING FLAG. IF FLAG NE 'X'. IF FUNCTION EQ 'D'. PERFORM CREATE_TABLE USING TABNAM. PERFORM DOWNLOAD_TABLE USING TABNAM. ELSE. IF FUNCTION EQ 'U'. PERFORM CREATE_TABLE USING TABNAM. PERFORM UPLOAD_TABLE USING TABNAM. ENDIF. * ELSE. MESSAGE S000 WITH 'The proposed table doesn''t exist.'. ENDIF. ENDIF. *---------------------------------------------------------------------* * FORM GET_FILENAME * *---------------------------------------------------------------------* * Name of the directory. *---------------------------------------------------------------------* FORM GET_FILENAME CHANGING LISTNAME. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING DEF_FILENAME = LISTNAME DEF_PATH = 'C:\downloads\list' MASK = ',*.*,*.*. ' MODE = 'S' TITLE = 'Save as' IMPORTING FILENAME = LISTNAME
EXCEPTIONS INV_WINSYS =1 NO_BATCH =2 SELECTION_CANCEL = 3 SELECTION_ERROR = 4 OTHERS = 5. ENDFORM. *---------------------------------------------------------------------* * FORM LOAD_DATA * *---------------------------------------------------------------------* * Specifies the path and table name *---------------------------------------------------------------------* FORM LOAD_DATA USING MY_TAB. DATA: W_FILE LIKE PCFILE-PATH. W_FILE = LISTNAME. CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME' EXPORTING COMPLETE_FILENAME = W_FILE IMPORTING DRIVE = ONE PATH = TWO EXCEPTIONS INVALID_DRIVE = 1 INVALID_EXTENSION = 2 INVALID_NAME =3 INVALID_PATH =4 OTHERS = 5. CONCATENATE ONE ':' TWO INTO FILEPATH. CONCATENATE FILEPATH MY_TAB '.txt' INTO FILE_TAB. ENDFORM. *---------------------------------------------------------------------* * FORM DOWNLOAD_TABLE *---------------------------------------------------------------------* * Downloads the table data. *---------------------------------------------------------------------* FORM DOWNLOAD_TABLE USING MY_TAB. SELECT * INTO TABLE <ROW> FROM (MY_TAB). ASSIGN <ROW> TO <TABLE>.
CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING FILENAME = FILE_TAB FILETYPE = 'ASC' TABLES DATA_TAB = <TABLE> EXCEPTIONS FILE_WRITE_ERROR =1 NO_BATCH =2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE =4 NO_AUTHORITY =5 UNKNOWN_ERROR = 6. IF SY-SUBRC EQ 0. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING TITEL = 'Successful Download' TXT1 = 'All the data from the table' TXT2 = 'was correctly downloaded.'. ELSE. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING TITEL = 'Download Error!' TXT1 = 'The data of the table' TXT2 = 'couldn''t be downloaded.'. ENDIF. ENDFORM. *---------------------------------------------------------------------* * FORM UPLOAD_TABLE * *---------------------------------------------------------------------* * Table Upload. *---------------------------------------------------------------------* FORM UPLOAD_TABLE USING MY_TAB. ASSIGN <ROW> TO <TABLE>. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = FILE_TAB FILETYPE = 'ASC' IMPORTING FILELENGTH = LONG TABLES
DATA_TAB = <TABLE> EXCEPTIONS FILE_OPEN_ERROR =1 FILE_READ_ERROR =2 NO_BATCH =3 GUI_REFUSE_FILETRANSFER = 4 INVALID_TYPE =5 NO_AUTHORITY =6 UNKNOWN_ERROR = 7. MODIFY (MY_TAB) FROM TABLE <TABLE>. IF SY-SUBRC EQ 0. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING TITEL = 'Successful Upload' TXT1 = 'All the data from the table' TXT2 = 'was correctly uploaded.'. ELSE. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING TITEL = 'Upload Error!' TXT1 = 'The data of the table' TXT2 = 'couldn''t be uploaded.'. ENDIF. ENDFORM. *---------------------------------------------------------------------* * FORM CREATE_TABLE * *---------------------------------------------------------------------* * Creates a dynamic internal table. *---------------------------------------------------------------------* FORM CREATE_TABLE USING MY_TAB. CREATE DATA DATAREF TYPE (MY_TAB). ASSIGN DATAREF->* TO <FS>. DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ). LOOP AT DESCR_STRUCT_REF->COMPONENTS ASSIGNING <COMPONENT>. WA_FCAT-FIELDNAME = <COMPONENT>-NAME. WA_FCAT-REF_TABLE = MY_TAB. WA_FCAT-REF_FIELD = <COMPONENT>-NAME. APPEND WA_FCAT TO IT_FIELDCATALOG. ENDLOOP.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE EXPORTING IT_FIELDCATALOG = IT_FIELDCATALOG IMPORTING EP_TABLE = DATAREF EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 1 OTHERS = 2. ASSIGN DATAREF->* TO <ROW>. ENDFORM. *&---------------------------------------------------------------------* *& Form VERIFY_TABLE *&---------------------------------------------------------------------* * The table must exist! *----------------------------------------------------------------------* FORM VERIFY_TABLE USING TABNAM CHANGING FLAG. SELECT SINGLE TABNAME INTO (TABNAME) FROM DD02L WHERE TABNAME EQ TABNAM. IF SY-SUBRC NE 0. FLAG = 'X'. ENDIF. ENDFORM.
exit. endif. * Exists? select single * from trdir where name = program. if sy-subrc <> 0. write: / 'Program does not exists!'. exit. endif. * Does it have a current generated version? data: f1 type d, f3 type d. data: f2 type t, f4 type t. EXEC SQL. SELECT UDAT, UTIME, SDAT, STIME INTO :F1, :F2, :F3, :F4 FROM D010LINF WHERE PROG = :PROGRAM ENDEXEC. if f1 < f3 or ( f1 = f3 and f2 < f4 ). write: / 'The program has no recent generated version!'. exit. endif. * Compose a new program name data: new_name(30), i type i, j type i. new_name = program. do 30 times. i = sy-index - 1. new_name+i(1) = '_'. * Search for acceptable program name variations j = 0. select * from trdir where name like new_name. j = j + 1. endselect. if j = 1. exit. endif. new_name = program. enddo. * Cannot generate appropriate program name if j > 1. write: / 'Cannot generate appropriate program name'. exit. endif. * Check if it is already hidden data: f5(30). EXEC SQL. SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME ENDEXEC. if f5 is initial.
* There is no such hidden program, hide it EXEC SQL. UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM ENDEXEC. concatenate 'Program' :program 'was hidden.' into message separated by space. else. * There is already a hidden program there, unhide it EXEC SQL. UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME ENDEXEC. concatenate 'Program' :program 'was restored.' into message separated by space. endif. write message. *** end of program
Help
* * TRDIR entries that are in the program uploaded. Instead, * * current users stats are used. * * - this program allows selection of reports from a list or * * a single report can be tuped in and uploaded * * - this program also updates TADIR so that a development class* * is assigned to the program * * - this program checks to see if the program already has a * * TRDIR entry, and if it does, warns the user * * - this program will save/restore the program documenation too* * * * * * * *---------------------------------------------------------------------* REPORT ZKBPROGS NO STANDARD PAGE HEADING LINE-SIZE 255. *---------------------------------------------------------------------* * Declare Database Objects * *---------------------------------------------------------------------* tables: DOKIL, TRDIR. *---------------------------------------------------------------------* * Constants* CONSTANTS: MC_TRDIR_IDENTIFIER(72) TYPE C VALUE '%&%& RDIR', MC_REPORT_IDENTIFIER(72) TYPE C VALUE '%&%& REPO', MC_TEXT_IDENTIFIER(72) TYPE C VALUE '%&%& TEXP', MC_THEAD_IDENTIFIER(72) TYPE C VALUE '%&%& HEAD', MC_DOC_IDENTIFIER(72) TYPE C VALUE '%&%& DOKL', MC_TRDIR_SHORT(4) TYPE C VALUE 'RDIR', MC_REPORT_SHORT(4) TYPE C VALUE 'REPO', MC_TEXT_SHORT(4) TYPE C VALUE 'TEXP', MC_THEAD_SHORT(4) TYPE C VALUE 'HEAD', MC_DOC_SHORT(4) TYPE C VALUE 'DOKP'. *---------------------------------------------------------------------* *---------------------------------------------------------------------* * Declare Module level data structures * *---------------------------------------------------------------------* DATA: BEGIN OF MTAB_PROGRAM_SOURCE OCCURS 0, LINE(72) TYPE C,
END OF MTAB_PROGRAM_SOURCE. MTAB_PROGRAM_TRDIR LIKE TRDIR OCCURS 0 WITH HEADER LINE. MTAB_PROGRAM_TEXTS LIKE TEXTPOOL OCCURS 0 WITH HEADER LINE. MSTR_THEAD LIKE THEAD. BEGIN OF MTAB_PROGRAM_FILE OCCURS 0, LINE(275) TYPE C, END OF MTAB_PROGRAM_FILE. DATA: BEGIN OF MTAB_DIRECTORY OCCURS 0, NAME LIKE TRDIR-NAME, DESC(72) TYPE C, SAVENAME LIKE RLGRAP-FILENAME, END OF MTAB_DIRECTORY. DATA: BEGIN OF MTAB_PROGRAM_DOCUMENTATION OCCURS 0, LINE(255) TYPE C, END OF MTAB_PROGRAM_DOCUMENTATION. *---------------------------------------------------------------------* * Selection Screen * *---------------------------------------------------------------------* *-- Options for upload/download of programs SELECTION-SCREEN BEGIN OF BLOCK FRM_OPTIONS WITH FRAME TITLE TEXTUDL. PARAMETERS: RB_DOWN RADIOBUTTON GROUP UDL DEFAULT 'X'. " Download reports SELECTION-SCREEN BEGIN OF BLOCK FRM_TRDIR WITH FRAME TITLE TEXT-DIR. SELECT-OPTIONS: S_NAME FOR TRDIR-NAME, " Program Name S_SUBC FOR TRDIR-SUBC " Program Type DEFAULT 'F' OPTION EQ SIGN E," Exclude Functions by default S_CNAM FOR TRDIR-CNAM " Created by DEFAULT SY-UNAME, S_UNAM FOR TRDIR-UNAM, " Last Changed by S_CDAT FOR TRDIR-CDAT, " Creation date S_UDAT FOR TRDIR-UDAT. " Last update date SELECTION-SCREEN END OF BLOCK FRM_TRDIR. *-- Options for uploading programs PARAMETERS: RB_UP RADIOBUTTON GROUP UDL. " Upload reports SELECTION-SCREEN BEGIN OF BLOCK FRM_UPLOAD WITH FRAME TITLE TEXTUPL. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(29) TEXT-SNG. PARAMETERS: RB_FILE RADIOBUTTON GROUP HOW DEFAULT 'X'. SELECTION-SCREEN COMMENT 33(42) TEXT-FNA. SELECTION-SCREEN END OF LINE. PARAMETERS: RB_LIST RADIOBUTTON GROUP HOW. SELECTION-SCREEN END OF BLOCK FRM_UPLOAD. SELECTION-SCREEN END OF BLOCK FRM_OPTIONS. *-- Options for up/downloading programs SELECTION-SCREEN BEGIN OF BLOCK FRM_FILEN WITH FRAME TITLE TEXT-FIL. PARAMETERS: DATA: DATA: DATA: DATA:
RB_DOS RADIOBUTTON GROUP FIL DEFAULT 'X', " Save to local RB_UNIX RADIOBUTTON GROUP FIL, " Save to UNIX P_PATH LIKE RLGRAP-FILENAME " Path to save files to DEFAULT 'c:\temp\'. SELECTION-SCREEN END OF BLOCK FRM_FILEN. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-LOW. CALL FUNCTION 'F4_PROGRAM' EXPORTING OBJECT = S_NAME-LOW SUPPRESS_SELECTION = 'X' IMPORTING RESULT = S_NAME-LOW EXCEPTIONS OTHERS = 1. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-HIGH. CALL FUNCTION 'F4_PROGRAM' EXPORTING OBJECT = S_NAME-HIGH SUPPRESS_SELECTION = 'X' IMPORTING RESULT = S_NAME-HIGH EXCEPTIONS OTHERS = 1. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-LOW. PERFORM GET_NAME USING 'S_UNAM-LOW' CHANGING S_UNAM-LOW. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-HIGH. PERFORM GET_NAME USING 'S_UNAM-HIGH' CHANGING S_UNAM-HIGH. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-LOW. PERFORM GET_NAME USING 'S_CNAM-LOW' CHANGING S_CNAM-LOW. AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-HIGH. PERFORM GET_NAME USING 'S_CNAM-HIGH' CHANGING S_CNAM-HIGH. TOP-OF-PAGE. IF RB_LIST = 'X'. FORMAT COLOR COL_HEADING. NEW-LINE. WRITE: AT 3 TEXT-H01, AT 15 TEXT-H03. FORMAT COLOR OFF. ENDIF. AT LINE-SELECTION. CHECK RB_LIST = 'X'. " only do in list mode READ LINE SY-CUROW FIELD VALUE MTAB_DIRECTORY-SAVENAME. *-- Read file into an internal table PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE USING MTAB_DIRECTORY-SAVENAME. *-- Split table into TADIR entry, report lines, and report text PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE MTAB_PROGRAM_SOURCE MTAB_PROGRAM_TEXTS MTAB_PROGRAM_DOCUMENTATION CHANGING TRDIR MSTR_THEAD.
*-- Save all of the data PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE MTAB_PROGRAM_TEXTS MTAB_PROGRAM_DOCUMENTATION USING TRDIR MSTR_THEAD. *---------------------------------------------------------------------* * Start of processing * *---------------------------------------------------------------------* START-OF-SELECTION. FORMAT COLOR COL_NORMAL. IF RB_DOWN = 'X'. PERFORM DOWNLOAD_REPORTS. ELSEIF RB_UP = 'X'. PERFORM UPLOAD_REPORTS. ENDIF. END-OF-SELECTION. IF RB_DOWN = 'X'. CONCATENATE P_PATH 'directory.txt' INTO P_PATH. PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_DIRECTORY USING P_PATH. ENDIF. *--------------------------------------------------------------------* * FORM UPLOAD_REPORTS * *--------------------------------------------------------------------* FORM UPLOAD_REPORTS. *-- Can upload a reports entered in selection criteria or *-- select from a list. List can be from index.txt in same directory *-- (created by the download) or by reading the first line of each file *-- in the directory. IF RB_FILE = 'X'. " Upload single program from a file *-- Read file into an internal table PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE USING P_PATH. *-- Split table into TADIR entry, report lines, and report text PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE MTAB_PROGRAM_SOURCE MTAB_PROGRAM_TEXTS MTAB_PROGRAM_DOCUMENTATION CHANGING TRDIR MSTR_THEAD. *-- Save all of the data PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE MTAB_PROGRAM_TEXTS MTAB_PROGRAM_DOCUMENTATION USING TRDIR MSTR_THEAD. ELSEIF RB_LIST = 'X'. " Show list for user to choose from
*-- get list of report names/descriptions from directory text CONCATENATE P_PATH 'directory.txt' INTO P_PATH. PERFORM READ_REPORT_FROM_DISK TABLES MTAB_DIRECTORY USING P_PATH. SORT MTAB_DIRECTORY. *-- Write out list of report names/descriptions LOOP AT MTAB_DIRECTORY. WRITE: / MTAB_DIRECTORY-NAME UNDER TEXT-H01, MTAB_DIRECTORY-DESC UNDER TEXT-H03, MTAB_DIRECTORY-SAVENAME. ENDLOOP. *-- Process user selections for reports to upload. ENDIF. ENDFORM. " upload_reports *--------------------------------------------------------------------* * FORM DOWNLOAD_REPORTS * *--------------------------------------------------------------------* * From the user selections, get all programs that meet the * * criteria, and save them in ftab_program_directory. * * Also save the report to disk. * *--------------------------------------------------------------------* FORM DOWNLOAD_REPORTS. DATA: LC_FULL_FILENAME LIKE RLGRAP-FILENAME. *-- The table is put into an internal table because the program will *-- abend if multiple transfers to a dataset occur within a SELECT/ *-- ENDSELCT (tested on 3.1H) SELECT * FROM TRDIR INTO TABLE MTAB_PROGRAM_TRDIR WHERE NAME IN S_NAME AND SUBC IN S_SUBC AND CNAM IN S_CNAM AND UNAM IN S_UNAM AND CDAT IN S_CDAT AND UDAT IN S_UDAT. LOOP AT MTAB_PROGRAM_TRDIR. *-- Clear out text and source code tables CLEAR: MTAB_PROGRAM_FILE, MTAB_PROGRAM_SOURCE, MTAB_PROGRAM_TEXTS, MTAB_PROGRAM_DOCUMENTATION. REFRESH: MTAB_PROGRAM_FILE, MTAB_PROGRAM_SOURCE, MTAB_PROGRAM_TEXTS, MTAB_PROGRAM_DOCUMENTATION. *-- Get the report
READ REPORT MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_SOURCE. *-- Get the text for the report READ TEXTPOOL MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_TEXTS. *-- Get the documentation for the report CLEAR DOKIL. SELECT * UP TO 1 ROWS FROM DOKIL WHERE ID = 'RE' AND OBJECT = MTAB_PROGRAM_TRDIR-NAME AND LANGU = SY-LANGU AND TYP = 'E' ORDER BY VERSION DESCENDING. ENDSELECT. *-- Documentation exists for this object IF SY-SUBRC = 0. CALL FUNCTION 'DOCU_READ' EXPORTING ID = DOKIL-ID LANGU = DOKIL-LANGU OBJECT = DOKIL-OBJECT TYP = DOKIL-TYP VERSION = DOKIL-VERSION IMPORTING HEAD = MSTR_THEAD TABLES LINE = MTAB_PROGRAM_DOCUMENTATION EXCEPTIONS OTHERS = 1. ENDIF. *-- Put the report code and texts into a single file *-- Put the identifier line in so that the start of the TRDIR line *-- is marked CONCATENATE MC_TRDIR_IDENTIFIER MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_FILE-LINE. APPEND MTAB_PROGRAM_FILE. *-- Add the TRDIR line MTAB_PROGRAM_FILE-LINE = MTAB_PROGRAM_TRDIR. APPEND MTAB_PROGRAM_FILE. *-- Put the identifier line in so that the start of the report code *-- is marked CONCATENATE MC_REPORT_IDENTIFIER MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_FILE-LINE. APPEND MTAB_PROGRAM_FILE. *-- Add the report code LOOP AT MTAB_PROGRAM_SOURCE. MTAB_PROGRAM_FILE = MTAB_PROGRAM_SOURCE. APPEND MTAB_PROGRAM_FILE. ENDLOOP. *-- Put the identifier line in so that the start of the report text *-- is marked CONCATENATE MC_TEXT_IDENTIFIER MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_FILE-LINE. APPEND MTAB_PROGRAM_FILE. *-- Add the report texts
LOOP AT MTAB_PROGRAM_TEXTS. MTAB_PROGRAM_FILE = MTAB_PROGRAM_TEXTS. APPEND MTAB_PROGRAM_FILE. ENDLOOP. *-- Put the identifier line in so that the start of the THEAD record *-- is marked CONCATENATE MC_THEAD_IDENTIFIER MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_FILE-LINE. APPEND MTAB_PROGRAM_FILE. MTAB_PROGRAM_FILE = MSTR_THEAD. APPEND MTAB_PROGRAM_FILE. *-- Put the identifier line in so that the start of the report *-- documentation is marked CONCATENATE MC_DOC_IDENTIFIER MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_FILE-LINE. APPEND MTAB_PROGRAM_FILE. *-- Add the report documentation LOOP AT MTAB_PROGRAM_DOCUMENTATION. MTAB_PROGRAM_FILE = MTAB_PROGRAM_DOCUMENTATION. APPEND MTAB_PROGRAM_FILE. ENDLOOP. *-- Make the fully pathed filename that report will be saved to CONCATENATE P_PATH MTAB_PROGRAM_TRDIR-NAME '.txt' INTO LC_FULL_FILENAME. PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_PROGRAM_FILE USING LC_FULL_FILENAME. *-- Write out message with Program Name/Description READ TABLE MTAB_PROGRAM_TEXTS WITH KEY ID = 'R'. IF SY-SUBRC = 0. MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME. MTAB_DIRECTORY-DESC = MTAB_PROGRAM_TEXTS-ENTRY. MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME. APPEND MTAB_DIRECTORY. WRITE: / MTAB_PROGRAM_TRDIR-NAME, MTAB_PROGRAM_TEXTS-ENTRY(65) COLOR COL_HEADING. ELSE. MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME. MTAB_DIRECTORY-DESC = 'No description available'. MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME. APPEND MTAB_DIRECTORY. WRITE: / MTAB_PROGRAM_TRDIR-NAME. ENDIF. ENDLOOP. ENDFORM. " BUILD_PROGRAM_DIRECTORY *--------------------------------------------------------------------* * FORM SAVE_TABLE_TO_FILE * *--------------------------------------------------------------------* * ........ * *--------------------------------------------------------------------*
* --> FTAB_TABLE * * --> F_FILENAME * *--------------------------------------------------------------------* FORM SAVE_TABLE_TO_FILE TABLES FTAB_TABLE USING F_FILENAME. IF RB_DOS = 'X'. " Save file to presentation server CALL FUNCTION 'WS_DOWNLOAD' EXPORTING FILENAME = F_FILENAME FILETYPE = 'ASC' TABLES DATA_TAB = FTAB_TABLE EXCEPTIONS OTHERS = 4. IF SY-SUBRC NE 0. WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE, F_FILENAME COLOR COL_NEGATIVE. ENDIF. ELSE. " Save file to application server OPEN DATASET F_FILENAME FOR OUTPUT IN TEXT MODE. IF SY-SUBRC = 0. LOOP AT FTAB_TABLE. TRANSFER FTAB_TABLE TO F_FILENAME. IF SY-SUBRC NE 0. WRITE: / 'Error writing record to file;' COLOR COL_NEGATIVE, F_FILENAME COLOR COL_NEGATIVE. ENDIF. ENDLOOP. ELSE. WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE, F_FILENAME COLOR COL_NEGATIVE. ENDIF. ENDIF. " End RB_DOS ENDFORM. " SAVE_PROGRAM *--------------------------------------------------------------------* * FORM READ_REPORT_FROM_DISK * *--------------------------------------------------------------------* * Read report into internal table. Can read from local or * * remote computer * *--------------------------------------------------------------------* FORM READ_REPORT_FROM_DISK TABLES FTAB_TABLE USING F_FILENAME. DATA: LC_MESSAGE(128) TYPE C. CLEAR FTAB_TABLE. REFRESH FTAB_TABLE. IF RB_DOS = 'X'. TRANSLATE F_FILENAME USING '/\'. " correct slash for Dos PC file
CALL FUNCTION 'WS_UPLOAD' EXPORTING FILENAME = F_FILENAME FILETYPE = 'ASC' TABLES DATA_TAB = FTAB_TABLE EXCEPTIONS CONVERSION_ERROR = 1 FILE_OPEN_ERROR = 2 FILE_READ_ERROR = 3 INVALID_TABLE_WIDTH = 4 INVALID_TYPE = 5 NO_BATCH = 6 UNKNOWN_ERROR = 7 OTHERS = 8. IF SY-SUBRC >< 0. WRITE: / 'Error reading file from local PC' COLOR COL_NEGATIVE. ENDIF. ELSEIF RB_UNIX = 'X'. TRANSLATE F_FILENAME USING '\/'. " correct slash for unix OPEN DATASET F_FILENAME FOR INPUT MESSAGE LC_MESSAGE IN TEXT MODE. IF SY-SUBRC = 0. DO. READ DATASET F_FILENAME INTO FTAB_TABLE. IF SY-SUBRC = 0. APPEND FTAB_TABLE. ELSE. EXIT. ENDIF. ENDDO. CLOSE DATASET F_FILENAME. ELSE. WRITE: / 'Error reading file from remote computer' COLOR COL_NEGATIVE, / LC_MESSAGE, / F_FILENAME. SY-SUBRC = 4. ENDIF. ENDIF. ENDFORM. " READ_REPORT_FROM_DISK *--------------------------------------------------------------------* * FORM SPLIT_INCOMING_FILE * *--------------------------------------------------------------------* * ........ * *--------------------------------------------------------------------* * --> FTAB_PROGRAM_FILE * * --> FTAB_PROGRAM_SOURCE * * --> ` * * --> FTAB_PROGRAM_TEXTS *
*--------------------------------------------------------------------* FORM SPLIT_INCOMING_FILE TABLES FTAB_PROGRAM_FILE STRUCTURE MTAB_PROGRAM_FILE FTAB_PROGRAM_SOURCE STRUCTURE MTAB_PROGRAM_SOURCE FTAB_PROGRAM_TEXTS STRUCTURE MTAB_PROGRAM_TEXTS FTAB_PROGRAM_DOCUMENTATION STRUCTURE MTAB_PROGRAM_DOCUMENTATION CHANGING FSTR_TRDIR FSTR_THEAD. DATA: LC_DATATYPE(4) TYPE C, " Type of data, REPO, TEXP, RDIR LC_PROGRAM_FILE LIKE MTAB_PROGRAM_FILE. LOOP AT FTAB_PROGRAM_FILE. LC_PROGRAM_FILE = FTAB_PROGRAM_FILE. CASE LC_PROGRAM_FILE(9). WHEN MC_TRDIR_IDENTIFIER. LC_DATATYPE = MC_TRDIR_SHORT. WHEN MC_REPORT_IDENTIFIER. LC_DATATYPE = MC_REPORT_SHORT. WHEN MC_TEXT_IDENTIFIER. LC_DATATYPE = MC_TEXT_SHORT. WHEN MC_DOC_IDENTIFIER. LC_DATATYPE = MC_DOC_SHORT. WHEN MC_THEAD_IDENTIFIER. LC_DATATYPE = MC_THEAD_SHORT. WHEN OTHERS. " Actual contents of report, trdir, or text CASE LC_DATATYPE. WHEN MC_TRDIR_SHORT. FSTR_TRDIR = FTAB_PROGRAM_FILE. WHEN MC_REPORT_SHORT. FTAB_PROGRAM_SOURCE = FTAB_PROGRAM_FILE. APPEND FTAB_PROGRAM_SOURCE. WHEN MC_TEXT_SHORT. FTAB_PROGRAM_TEXTS = FTAB_PROGRAM_FILE. APPEND FTAB_PROGRAM_TEXTS. WHEN MC_THEAD_SHORT. FSTR_THEAD = FTAB_PROGRAM_FILE. WHEN MC_DOC_SHORT. FTAB_PROGRAM_DOCUMENTATION = FTAB_PROGRAM_FILE. APPEND FTAB_PROGRAM_DOCUMENTATION. ENDCASE. ENDCASE. ENDLOOP. ENDFORM. " SPLIT_INCOMING_FILE *--------------------------------------------------------------------* * FORM INSERT_NEW_REPORT* *--------------------------------------------------------------------* * ........ * *--------------------------------------------------------------------*
* --> FTAB_PROGRAM_SOURCE * * --> FTAB_PROGRAM_TEXTS * * --> F_TRDIR * *--------------------------------------------------------------------* FORM INSERT_NEW_REPORT TABLES FTAB_PROGRAM_SOURCE STRUCTURE MTAB_PROGRAM_SOURCE FTAB_PROGRAM_TEXTS STRUCTURE MTAB_PROGRAM_TEXTS FTAB_PROGRAM_DOCUMENTATION STRUCTURE MTAB_PROGRAM_DOCUMENTATION USING FSTR_TRDIR LIKE TRDIR FSTR_THEAD LIKE MSTR_THEAD. DATA: LC_OBJ_NAME LIKE E071-OBJ_NAME, LC_LINE2(40) TYPE C, LC_ANSWER(1) TYPE C. *-- read trdir to see if the report already exists, if it does, prompt *-- user to overwrite or abort. SELECT SINGLE * FROM TRDIR WHERE NAME = FSTR_TRDIR-NAME. IF SY-SUBRC = 0. " Already exists CONCATENATE 'want to overwrite report' FSTR_TRDIR-NAME INTO LC_LINE2 SEPARATED BY SPACE. CONCATENATE LC_LINE2 '?' INTO LC_LINE2. CALL FUNCTION 'POPUP_TO_CONFIRM_STEP' EXPORTING DEFAULTOPTION = 'N' TEXTLINE1 = 'The selected report already exists, do you' TEXTLINE2 = LC_LINE2 TITEL = 'Report already exists' CANCEL_DISPLAY = SPACE IMPORTING ANSWER = LC_ANSWER EXCEPTIONS OTHERS = 1. ELSE. LC_ANSWER = 'J'. ENDIF. IF LC_ANSWER = 'J'. *-- Create the TADIR entry. (TRDIR entry created by INSERT REPORT) LC_OBJ_NAME = TRDIR-NAME. CALL FUNCTION 'TR_TADIR_POPUP_ENTRY_E071' EXPORTING WI_E071_PGMID = 'R3TR' WI_E071_OBJECT = 'PROG' WI_E071_OBJ_NAME = LC_OBJ_NAME WI_TADIR_DEVCLASS = '$TMP' EXCEPTIONS EXIT = 3 OTHERS = 4. IF SY-SUBRC = 0.
*-- Create Report INSERT REPORT FSTR_TRDIR-NAME FROM FTAB_PROGRAM_SOURCE. *-- Create Texts INSERT TEXTPOOL FSTR_TRDIR-NAME FROM FTAB_PROGRAM_TEXTS LANGUAGE SY-LANGU. *-- Save Documentation CALL FUNCTION 'DOCU_UPDATE' EXPORTING HEAD = FSTR_THEAD STATE = 'A' TYP = 'E' VERSION = '1' TABLES LINE = FTAB_PROGRAM_DOCUMENTATION EXCEPTIONS OTHERS = 1. ELSE. WRITE: / 'Error updating the TADIR entry' COLOR COL_NEGATIVE, 'Program' COLOR COL_NEGATIVE INTENSIFIED OFF, FSTR_TRDIR-NAME, 'was not loaded into SAP.' COLOR COL_NEGATIVE INTENSIFIED OFF. ENDIF. ELSE. WRITE: / FSTR_TRDIR-NAME COLOR COL_NEGATIVE, 'was not uploaded into SAP. Action cancelled by user' COLOR COL_NEGATIVE INTENSIFIED OFF. ENDIF. ENDFORM. " INSERT_NEW_REPORT *--------------------------------------------------------------------* * FORM GET_NAME * *--------------------------------------------------------------------* * ........ * *--------------------------------------------------------------------* * --> VALUE(F_FIELD) * * --> F_NAME * *--------------------------------------------------------------------* FORM GET_NAME USING VALUE(F_FIELD) CHANGING F_NAME. DATA: LTAB_FIELDS LIKE DYNPREAD OCCURS 0 WITH HEADER LINE, LC_PROG LIKE D020S-PROG, LC_DNUM LIKE D020S-DNUM. TRANSLATE F_FIELD TO UPPER CASE. refresh ltab_fields. LTAB_FIELDS-FIELDNAME = F_FIELD. append ltab_fields. LC_PROG = SY-REPID . LC_DNUM = SY-DYNNR . CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING DYNAME = LC_PROG DYNUMB = LC_DNUM TABLES
dynpfields = ltab_fields EXCEPTIONS OTHERS = 01. read table ltab_fields index 1. IF SY-SUBRC EQ 0. F_NAME = LTAB_FIELDS-FIELDVALUE. refresh ltab_fields. ENDIF. CALL FUNCTION 'F4_USER' EXPORTING OBJECT = F_NAME IMPORTING RESULT = F_NAME. ENDFORM. " GET_NAME Program Texts DIR FIL FNA H01 H03 SNG UDL UPL R P_PATH RB_DOS RB_DOWN RB_FILE RB_LIST RB_UNIX RB_UP S_CDAT S_CNAM S_NAME S_SUBC S_UDAT S_UNAM File Download Options (File Selection) File Options Enter filename below (under File Options) Prog Name Program Description Upload a single file Upload to SAP/Download from SAP File Upload Options Backup/Restore program source code with texts Path to save programs to Files on local computer Download Programs Upload a single file Select program(s) from a list Files on remote computer Upload Programs to SAP Date Created Created by UserID Program Name Program Type Date Changed Last Changed by UserID
New Site Address: http://abap.mirrorz.com Send any hints or tips to ABAP Hints & Tips . All submissions will be recognized along with the tip.
Get a cool web address Free subdomains from ShortURL.com