Document directory
- Include File: zhizi_tab_strip_top
- Include File: zhizi_tab_strip
The code below shows how to create non-Gui tab strips using ABAP. This is also used for the first time. It is faster and better than screen tabstrip.
REPORT YHISR_REPORT_TAB NO STANDARD PAGE HEADING.INCLUDE ZHIZI_TAB_STRIP_TOP.DATA: T_TAB1 TYPE TY_TAB_STRUC OCCURS 5 WITH HEADER LINE, T_TAB2 TYPE TY_TAB_STRUC OCCURS 5 WITH HEADER LINE.DATA: L_TAB1_MODE, L_TAB2_MODE.PERFORM FILL_TTAB.PERFORM FILL_TTAB2.PERFORM BUILD_TAB TABLES T_TAB1 USING 1 10 55 17 C_DEFAULT 'TestTab1'.PERFORM BUILD_TAB TABLES T_TAB2 USING 1 1 45 9 C_DEFAULT 'TestTab2'.AT LINE-SELECTION. IF G_TAB_HIDE_TEXT(7) = 'TestTab'. IF G_TAB_HIDE_TEXT = 'TestTab1'. L_TAB1_MODE = C_USER_ACTION. L_TAB2_MODE = C_DEFAULT. ELSE. L_TAB1_MODE = C_DEFAULT. L_TAB2_MODE = C_USER_ACTION. ENDIF. PERFORM BUILD_TAB TABLES T_TAB1 USING 1 10 55 17 L_TAB1_MODE 'TestTab1'. PERFORM BUILD_TAB TABLES T_TAB2 USING 1 1 45 9 L_TAB2_MODE 'TestTab2'. SY-LSIND = 0. SCROLL LIST INDEX SY-LSIND TO PAGE 1 LINE SY-STARO. SCROLL LIST INDEX SY-LSIND TO COLUMN SY-STACO. ENDIF.FORM FIRST. SKIP TO LINE 15. POSITION 20. WRITE 'First Tab Contents Here.'.ENDFORM.FORM SECOND. SKIP TO LINE 15. POSITION 20. WRITE 'Second Tab Contents Here.'.ENDFORM.FORM THIRD. SKIP TO LINE 15. POSITION 20. WRITE 'Third Tab Contents Here.'.ENDFORM.FORM FOURTH. SKIP TO LINE 15. POSITION 20. WRITE 'Fourth Tab Contents Here.'.ENDFORM.FORM FIFTH. SKIP TO LINE 15. POSITION 20. WRITE 'Fifth Tab Contents Here.'.ENDFORM.FORM ADDRESS. SKIP TO LINE 5. POSITION 5. WRITE '12936 Meadow Glen Lane, #32'. SKIP TO LINE 6. POSITION 5. WRITE 'Houston, TX 77973'.ENDFORM.FORM INFO. SKIP TO LINE 5. POSITION 5. WRITE 'Home Ph: (713) 233-4545'. SKIP TO LINE 6. POSITION 5. WRITE 'Work Ph: (713) 433-2215'. SKIP TO LINE 7. POSITION 5. WRITE 'Pager : (713) 433-2216'.ENDFORM.INCLUDE ZHIZI_TAB_STRIP.*&---------------------------------------------------------------------**& Form FILL_TTAB*&---------------------------------------------------------------------*FORM FILL_TTAB. PERFORM FILL_TABLE TABLES T_TAB1 USING 'First' 'FIRST' ''. PERFORM FILL_TABLE TABLES T_TAB1 USING 'Second' 'SECOND' ''. PERFORM FILL_TABLE TABLES T_TAB1 USING 'Third' 'THIRD' ''. PERFORM FILL_TABLE TABLES T_TAB1 USING 'Fourth One' 'FOURTH' 'X'. PERFORM FILL_TABLE TABLES T_TAB1 USING 'Tab Five' 'FIFTH' ''.ENDFORM. " FILL_TTAB*&---------------------------------------------------------------------**& Form FILL_TTAB2*&---------------------------------------------------------------------*FORM FILL_TTAB2.PERFORM FILL_TABLE TABLES T_TAB2 USING 'Customer Address' 'ADDRESS' ''.PERFORM FILL_TABLE TABLES T_TAB2 USING 'Other Information' 'INFO' 'X'.ENDFORM. " TILL_TTAB2
Include File: zhizi_tab_strip_top
*----------------------------------------------------------------------** INCLUDE ZHIZI_TAB_STRIP_TOP **----------------------------------------------------------------------*CONSTANTS: C_USER_ACTION TYPE C VALUE 'X', C_DEFAULT TYPE C VALUE ' '.TYPES: BEGIN OF TY_TAB_STRUC, LABEL(32), FORM(32), SEL, END OF TY_TAB_STRUC, TY_TAB TYPE STANDARD TABLE OF TY_TAB_STRUC.DATA: G_TAB_HIDE_TEXT(32).
Include File: zhizi_tab_strip
*&---------------------------------------------------------------------**& Form BUILD_TAB*&---------------------------------------------------------------------*FORM BUILD_TAB TABLES P_T_TAB TYPE TY_TAB USING VALUE(P_LEFT) VALUE(P_TOP) VALUE(P_RIGHT) VALUE(P_BOTTOM) VALUE(P_MODE) VALUE(P_TABNAME). DATA: L_LENGTH TYPE I VALUE 0, L_V_POS TYPE I, L_H_LINE(256), L_FIRST_TL_END TYPE I, L_SECOND_TL_BEGIN TYPE I, L_TAB_START TYPE I, L_PREV_SEL TYPE I. CLEAR L_H_LINE WITH '-'. " A long string of -------- READ TABLE P_T_TAB WITH KEY SEL = 'X'. L_PREV_SEL = SY-TABIX.* We want only one row to have sel = 'X'. Clear all of them. P_T_TAB-SEL = ''. MODIFY P_T_TAB TRANSPORTING SEL WHERE LABEL <> ''.* Now, set the appropriate tab IF P_MODE = C_USER_ACTION. L_V_POS = P_TOP + 1. IF SY-CUCOL > P_LEFT AND SY-CUCOL < P_RIGHT AND SY-CUROW = L_V_POS. L_LENGTH = P_LEFT + 1. LOOP AT P_T_TAB. L_LENGTH = L_LENGTH + STRLEN( P_T_TAB-LABEL ) + 3. IF SY-CUCOL < L_LENGTH. P_T_TAB-SEL = 'X'. MODIFY P_T_TAB TRANSPORTING SEL. EXIT. ENDIF. ENDLOOP. ENDIF. READ TABLE P_T_TAB WITH KEY SEL = 'X'. IF SY-SUBRC <> 0. "Hmmm. Let us set it to the previous tab P_T_TAB-SEL = 'X'. MODIFY P_T_TAB INDEX L_PREV_SEL TRANSPORTING SEL. ENDIF. ELSE. "p_mode = c_default : Set to the previous tab P_T_TAB-SEL = 'X'. MODIFY P_T_TAB INDEX L_PREV_SEL TRANSPORTING SEL. ENDIF. SKIP TO LINE P_TOP. POSITION P_LEFT. LOOP AT P_T_TAB. L_LENGTH = STRLEN( P_T_TAB-LABEL ) + 2. WRITE AT (L_LENGTH) L_H_LINE. ENDLOOP. L_V_POS = P_TOP + 1. SKIP TO LINE L_V_POS. POSITION P_LEFT. LOOP AT P_T_TAB. L_LENGTH = STRLEN( P_T_TAB-LABEL ). IF P_T_TAB-SEL = 'X'. L_FIRST_TL_END = SY-COLNO + 1. WRITE: '|' NO-GAP, AT (L_LENGTH) P_T_TAB-LABEL COLOR COL_HEADING INTENSIFIED OFF NO-GAP, '|'. L_SECOND_TL_BEGIN = SY-COLNO - 2. ELSE. WRITE: '|' NO-GAP, AT (L_LENGTH) P_T_TAB-LABEL HOTSPOT COLOR COL_HEADING INTENSIFIED NO-GAP, '|'. ENDIF. ENDLOOP. G_TAB_HIDE_TEXT = P_TABNAME. HIDE G_TAB_HIDE_TEXT. ADD 1 TO L_V_POS. SKIP TO LINE L_V_POS. L_LENGTH = P_RIGHT - P_LEFT - 1. WRITE: AT P_LEFT '|' NO-GAP, AT (L_LENGTH) L_H_LINE NO-GAP, '|'. L_LENGTH = L_SECOND_TL_BEGIN - L_FIRST_TL_END. WRITE: AT L_FIRST_TL_END(L_LENGTH) '' NO-GAP. ADD 1 TO L_V_POS. SKIP TO LINE L_V_POS. WHILE SY-LINNO < P_BOTTOM. WRITE: AT P_LEFT '|', AT P_RIGHT '|'. ADD 1 TO L_V_POS. SKIP TO LINE L_V_POS. ENDWHILE. L_LENGTH = P_RIGHT - P_LEFT + 1. WRITE AT P_LEFT(L_LENGTH) L_H_LINE. READ TABLE P_T_TAB WITH KEY SEL = 'X'. PERFORM (P_T_TAB-FORM) IN PROGRAM (SY-CPROG).ENDFORM. " BUILD_TAB*&---------------------------------------------------------------------**& Form FILL_TABLE*&---------------------------------------------------------------------*FORM FILL_TABLE TABLES P_T_TAB TYPE TY_TAB USING VALUE(P_LABEL) VALUE(P_FORM) VALUE(P_SEL). P_T_TAB-LABEL = P_LABEL. P_T_TAB-FORM = P_FORM. P_T_TAB-SEL = P_SEL. APPEND P_T_TAB.ENDFORM. " FILL_TABLE