Skip to Content
avatar image
Former Member

User exit....Need Help

Hi All,

We have two legacy(same) production Systems for two different corporate locations.

We are implementing SAP(FI only) and planning for a single database for the two legacy Systems into one.

But our customers wants to go to a particular Corporate legacy system so we have decided to create a ZZfield for the customer master table KNA1.

We appended this field in the table KNA1.

We have to pop-up a screen where customer can select by the Corporate office and company code.

Is there any screen exit or BADI to work on?

Is there any alternative way we can work up by using screen numbers?

If possible send me some coding too.

I appreciate your help.

Thankyou.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    May 05, 2006 at 03:34 AM

    Hey Andy,

    I have worked on a similar scenario. My case was to enhance a scree using BADI. In the original screen, we had some mandatory fields : sflight-connid , sflight-carrid AND sflight-fldate.

    After you fill these details , you will get the details about the sflight-price,

    sflight-currency, and

    sflight-planetype.

    Now we had to add two additional fields to the original screen . The additional fileds were :

    sflight-seatsmax,

    and sflight-seatsocc.

    Here i am giving the code of the original program <b>ZKUN_BADI_SCREEN2</b> and then the addtional prg to enhance the screen <b>ZKUN_SCREEN2_POOL</b>

    • Prog 1

    &----


    *& Report ZKUN_BADI_SCREEN2 *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT zkun_badi_screen2 .

    TABLES : sflight.

    DATA : program TYPE program,

    dynpro TYPE dynnr,

    exit TYPE REF TO zif_ex_kun_badi_screen1.

    DATA : num TYPE sy-dynnr VALUE '200'.

    DATA : BEGIN OF itab OCCURS 0,

    price TYPE sflight-price,

    currency TYPE sflight-currency,

    planetype TYPE sflight-planetype,

    seatsmax TYPE sflight-seatsmax,

    seatsocc TYPE sflight-seatsocc,

    END OF itab.

    DATA : flag TYPE i VALUE 0.

    CALL SCREEN 100.

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    MODULE user_command_0100 INPUT.

    CASE sy-ucomm.

    WHEN 'EXIT'.

    LEAVE PROGRAM.

    WHEN 'ENTER'.

    • MESSAGE i001(zmsg_kunal).

    SELECT price currency planetype seatsmax seatsocc FROM sflight

    INTO TABLE itab WHERE connid = sflight-connid AND carrid =

    sflight-carrid AND fldate = sflight-fldate..

    LOOP AT itab.

    sflight-price = itab-price.

    sflight-currency = itab-currency.

    sflight-planetype = itab-planetype.

    sflight-seatsmax = itab-seatsmax.

    sflight-seatsocc = itab-seatsocc.

    ENDLOOP.

    flag = 1.

    CALL METHOD exit->get

    EXPORTING

    flight = sflight.

    WHEN 'BACK'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    MODULE status_0100 OUTPUT.

    SET PF-STATUS 'MYMENU'.

    SET TITLEBAR 'HELLO'.

    IF flag = 1.

    LOOP AT SCREEN.

    IF screen-group1 = 'GR1'.

    screen-invisible = 0.

    MODIFY SCREEN.

    ENDIF.

    ENDLOOP.

    ENDIF.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Module initialize OUTPUT

    &----


    • text

    ----


    MODULE initialize OUTPUT.

    IF exit IS INITIAL.

    CALL METHOD cl_exithandler=>get_instance

    CHANGING

    instance = exit.

    ENDIF.

    CALL METHOD cl_exithandler=>set_instance_for_subscreens

    EXPORTING

    instance = exit.

    ENDMODULE. " initialize OUTPUT

    &----


    *& Module data_for_subscreen OUTPUT

    &----


    • text

    ----


    MODULE data_for_subscreen OUTPUT.

    program = sy-repid.

    dynpro = sy-dynnr.

    CALL METHOD cl_exithandler=>get_prog_and_dynp_for_subscr

    EXPORTING

    exit_name = 'ZKUN_BADI_SCREEN1'

    calling_program = program

    calling_dynpro = dynpro

    subscreen_area = 'SUB'

    IMPORTING

    called_program = program

    called_dynpro = dynpro.

    CALL METHOD exit->put

    IMPORTING

    flight = sflight.

    .

    ENDMODULE. " data_for_subscreen OUTPUT

    • Prog 2

    &----


    *& Module pool ZKUN_SCREEN2_POOL *

    *& *

    &----


    *& *

    *& *

    &----


    PROGRAM zkun_screen2_pool .

    TABLES : sflight.

    DATA: exit TYPE REF TO zif_ex_kun_badi_screen1,

    flight TYPE sflight.

    DATA: BEGIN OF struct,

    var1 TYPE sflight-paymentsum,

    var2 TYPE sflight-seatsmax_b,

    END OF struct.

    DATA: count TYPE i VALUE 0.

    &----


    *& Module STATUS_0200 OUTPUT

    &----


    • text

    ----


    MODULE status_0200 OUTPUT.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

    IF exit IS INITIAL.

    CALL METHOD cl_exithandler=>get_instance_for_subscreens

    CHANGING

    instance = exit.

    ELSE .

    count = 1.

    ENDIF.

    CALL METHOD exit->put

    IMPORTING

    flight = flight.

    SELECT paymentsum seatsmax_b FROM sflight INTO struct

    WHERE carrid = flight-carrid AND

    connid = flight-connid AND

    fldate = flight-fldate.

    ENDSELECT.

    sflight-seatsmax_b = struct-var2.

    sflight-paymentsum = struct-var1.

    IF count EQ 1.

    LOOP AT SCREEN.

    IF screen-group1 = 'GR1'.

    screen-invisible = 0.

    MODIFY SCREEN.

    ENDIF.

    ENDLOOP.

    ENDIF.

    ENDMODULE. " STATUS_0200 OUTPUT

    &----


    *& Module USER_COMMAND_0200 INPUT

    &----


    • text

    ----


    MODULE user_command_0200 INPUT.

    • CALL METHOD exit->get

    • EXPORTING

    • flight = flight.

    *

    ENDMODULE. " USER_COMMAND_0200 INPUT

    The scenario and steps are explained here ( I have done some modification in my code , but you can get the idea with this link ).

    http://help.sap.com/saphelp_47x200/helpdata/en/9d/12233a0edd7978e10000000a11402f/content.htm>

    Regards,

    Kunal.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 05, 2006 at 05:03 AM

    Hi Andy,

    I am pasting the code which finds USER EXIT for any transaction. You just need to give the T CODE and it will give you all the exits it has.

    REPORT z_find_userexit NO STANDARD PAGE HEADING.
    
    
    
    *&---------------------------------------------------------------------*
    
    *&  Enter the transaction code that you want to search through in order
    
    *&  to find which Standard SAP User Exits exists.
    
    *&
    
    *&---------------------------------------------------------------------*
    
    
    
    *&---------------------------------------------------------------------*
    
    *& Tables
    
    *&---------------------------------------------------------------------*
    
    
    
    TABLES : tstc,     "SAP Transaction Codes
    
             tadir,    "Directory of Repository Objects
    
             modsapt,  "SAP Enhancements - Short Texts
    
             modact,   "Modifications
    
             trdir,    "System table TRDIR
    
             tfdir,    "Function Module
    
             enlfdir,  "Additional Attributes for Function Modules
    
             tstct.    "Transaction Code Texts
    
    
    
    *&---------------------------------------------------------------------*
    
    *& Variables
    
    *&---------------------------------------------------------------------*
    
    
    
    DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
    
    DATA : field1(30).
    
    DATA : v_devclass LIKE tadir-devclass.
    
    
    
    *&---------------------------------------------------------------------*
    
    *& Selection Screen Parameters
    
    *&---------------------------------------------------------------------*
    
    SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
    
    SELECTION-SCREEN SKIP.
    
    PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
    
    SELECTION-SCREEN SKIP.
    
    SELECTION-SCREEN END OF BLOCK a01.
    
    
    
    *&---------------------------------------------------------------------*
    
    *& Start of main program
    
    *&---------------------------------------------------------------------*
    
    
    
    START-OF-SELECTION.
    
    
    
    * Validate Transaction Code
    
      SELECT SINGLE * FROM tstc
    
        WHERE tcode EQ p_tcode.
    
    
    
    * Find Repository Objects for transaction code
    
      IF sy-subrc EQ 0.
    
        SELECT SINGLE * FROM tadir
    
           WHERE pgmid    = 'R3TR'
    
             AND object   = 'PROG'
    
             AND obj_name = tstc-pgmna.
    
    
    
        MOVE : tadir-devclass TO v_devclass.
    
    
    
        IF sy-subrc NE 0.
    
          SELECT SINGLE * FROM trdir
    
             WHERE name = tstc-pgmna.
    
    
    
          IF trdir-subc EQ 'F'.
    
    
    
            SELECT SINGLE * FROM tfdir
    
              WHERE pname = tstc-pgmna.
    
    
    
            SELECT SINGLE * FROM enlfdir
    
              WHERE funcname = tfdir-funcname.
    
    
    
            SELECT SINGLE * FROM tadir
    
              WHERE pgmid    = 'R3TR'
    
                AND object   = 'FUGR'
    
                AND obj_name = enlfdir-area.
    
    
    
            MOVE : tadir-devclass TO v_devclass.
    
          ENDIF.
    
        ENDIF.
    
    
    
    * Find SAP Modifactions
    
        SELECT * FROM tadir
    
          INTO TABLE jtab
    
          WHERE pgmid    = 'R3TR'
    
            AND object   = 'SMOD'
    
            AND devclass = v_devclass.
    
    
    
        SELECT SINGLE * FROM tstct
    
          WHERE sprsl EQ sy-langu
    
            AND tcode EQ p_tcode.
    
    
    
        FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
    
        WRITE:/(19) 'Transaction Code - ',
    
        20(20) p_tcode,
    
        45(50) tstct-ttext.
    
        SKIP.
    
        IF NOT jtab[] IS INITIAL.
    
          WRITE:/(95) sy-uline.
    
          FORMAT COLOR COL_HEADING INTENSIFIED ON.
    
          WRITE:/1 sy-vline,
    
          2 'Exit Name',
    
          21 sy-vline ,
    
          22 'Description',
    
          95 sy-vline.
    
          WRITE:/(95) sy-uline.
    
    
    
          LOOP AT jtab.
    
            SELECT SINGLE * FROM modsapt
    
            WHERE sprsl = sy-langu AND
    
            name = jtab-obj_name.
    
            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
    
            WRITE:/1 sy-vline,
    
            2 jtab-obj_name HOTSPOT ON,
    
            21 sy-vline ,
    
            22 modsapt-modtext,
    
            95 sy-vline.
    
          ENDLOOP.
    
    
    
          WRITE:/(95) sy-uline.
    
          DESCRIBE TABLE jtab.
    
          SKIP.
    
          FORMAT COLOR COL_TOTAL INTENSIFIED ON.
    
          WRITE:/ 'No of Exits:' , sy-tfill.
    
        ELSE.
    
          FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    
          WRITE:/(95) 'No User Exit exists'.
    
        ENDIF.
    
      ELSE.
    
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    
        WRITE:/(95) 'Transaction Code Does Not Exist'.
    
      ENDIF.
    
    
    
    * Take the user to SMOD for the Exit that was selected.
    
    AT LINE-SELECTION.
    
      GET CURSOR FIELD field1.
    
      CHECK field1(4) EQ 'JTAB'.
    
      SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
    
                         .

    Hope it helps. Please reward if it was useful.

    Jignesh.

    Add comment
    10|10000 characters needed characters exceeded