Skip to Content
author's profile photo
Former Member

static subroutines

hi,

whats the diffarence b/w static subroutine and dynamic subroutine

can any one give me the example for the static subroutine

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:40 AM

    sample code static subroutine

    PERFORM datatest1.

    PERFORM datatest1.

    SKIP.

    PERFORM datatest2.

    PERFORM datatest2.

    FORM datatest1.

    TYPES f_word(5) TYPE c.

    DATA f_text TYPE f_word VALUE 'INIT'.

    WRITE f_text.

    f_text = '12345'.

    WRITE f_text.

    ENDFORM.

    FORM datatest2.

    TYPES f_word(5) TYPE c.

    STATICS f_text TYPE f_word VALUE 'INIT'.

    WRITE f_text.

    f_text = 'ABCDE'.

    WRITE f_text.

    ENDFORM.

    dynamic subroutine:

    TYPES word(10) TYPE c.

    DATA text TYPE word.

    text = '1234567890'. WRITE / text.

    PERFORM datatest.

    WRITE / text.

    FORM datatest.

    TYPES word(5) TYPE c.

    DATA text TYPE word.

    text = 'ABCDEFGHJK'. WRITE / text.

    ENDFORM.

    Calling Internal Subroutines :

    DATA: num1 TYPE i,

    num2 TYPE i,

    sum TYPE i.

    num1 = 2. num2 = 4.

    PERFORM addit.

    num1 = 7. num2 = 11.

    PERFORM addit.

    FORM addit.

    sum = num1 + num2.

    PERFORM out.

    ENDFORM.

    FORM out.

    WRITE: / 'Sum of', num1, 'and', num2, 'is', sum.

    ENDFORM.

    Calling External Subroutines :

    PERFORM header(demo_mod_tech_formpool_1) IF FOUND.

    report formpool.

    form header.

    write: / 'Program started by', sy-uname,

    / 'on host', sy-host,

    'date:', sy-datum, 'time:', sy-uzeit.

    uline.

    endform.

    form sub1.

    write: / 'Subroutine 1'.

    endform.

    form sub2.

    write: / 'Subroutine 2'.

    endform.

    reward points if helpful..........

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 28, 2007 at 10:21 AM

    Hi..

    When we define the Subroutine using the

    FORM ADD_DATA.

    ENDFORM.

    This is called statis subroutine.

    But when we generate a Subroutine dynamically using

    the INSERT statement it is called dynamic subroutine.

    reward if Helpful.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:37 AM

    hi,

    example is given below.

    REPORT Z0322_PERFORM.

    data : temp type i.

    perform static.

    temp = 10.

    perform dynamic using temp.

    perform dynamic2 changing temp.

    &----


    *& Form static

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form static .

    data : a type i,

    b type i,

    c type i.

    a = 10.

    b = 20.

    c = a + b .

    write :/ 'Statc --> ' , c.

    write :/ 'dynamic after call perform -->' , temp.

    endform. " static

    &----


    *& Form dynamic

    &----


    • text

    ----


    • -->P_TEMP text

    ----


    form dynamic using p_temp.

    write :/ 'dynamic --> ' , p_temp.

    temp = 20.

    endform. " dynamic

    &----


    *& Form dynamic2

    &----


    • text

    ----


    • <--P_TEMP text

    ----


    form dynamic2 changing temp.

    write :/ 'dynamic --> ' , temp.

    endform. " dynamic2

    check it out..

    regards.

    baskaran.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 11:36 AM

    hi

    AT LINE-SELECTION.

    GET CURSOR FIELD fld VALUE val.

    CASE fld.

    WHEN 'ITAB-MATNR'.

    WRITE:/ val.

    ENDCASE.

    CASE sy-lsind.

    WHEN '1'.

    SET PF-STATUS 'XX2'.

    SET TITLEBAR 'XX2'.

    IF itab1[] IS INITIAL.

    WRITE:/ 'no data found for itab1 in first secondary list'.

    ENDIF.

    LOOP AT itab1.

    WRITE:/30 itab1-matnr,60 itab1-vbeln.

    • hide itab1-matnr.

    ENDLOOP.

    WHEN '2'.

    SET PF-STATUS 'XX2'.

    SET TITLEBAR 'XX2'.

    LOOP AT itab.

    WRITE:/30 itab-matnr,60 itab-ernam.

    ENDLOOP.

    ENDCASE.

    AT USER-COMMAND.

    CASE sy-ucomm.

    WHEN 'SET'.

    IF sy-lsind = 1.

    WINDOW STARTING AT 5 3 ENDING AT 40 10.

    WRITE 'Select line for a second window'.

    ELSEIF sy-lsind = 2.

    WINDOW STARTING AT 45 10 ENDING AT 60 12.

    WRITE 'Last window'.

    ENDIF.

    regards

    kk.

    Add comment
    10|10000 characters needed characters exceeded