Skip to Content
avatar image
Former Member

Call a function module from within a sapscript form

not being an ABAPer i have the task of changing the Invoice SAPScript form.

i have made the necessary changes - just about... but they have asked that i include the VAT Number on the Invoice....

not too bad apart from different company codes have different vat numbers...

not knowing a better way to retrieve data from table V_001_B - i am using the print program -RFKORD50, is there a better way of getting the VAT Number by company code? I figured if i could call the FM to return the value, all well and good.., they do not want the print program changed if possible so was looking at alternate methods....

or am i trying to reinvent the wheel here?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Mar 18, 2010 at 02:11 PM

    HI,

    You can use a subroutine in the script and call the function module in a subroutine pool program instead of modifying the driver program.

    Check the link to call subroutines in sap script

    http://help.sap.com/saphelp_NW70EHP1/helpdata/en/d1/803279454211d189710000e8322d00/content.htm

    Thanks & Regards

    Sarves S

    Edited by: Sarves Sombhatla on Mar 18, 2010 7:42 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 25, 2010 at 02:09 PM

    thank you both! helpful answers! :o)

    anyway!

    i have written the program which is called from the SAPScript:

        /:       PERFORM GET_VATNUMBER IN PROGRAM ZFI_F140_OPERATIONS
        /:       USING &BKPF-BUKRS&
        /:       CHANGING &VATNUMBER&
        CE       VAT Registration No : &VATNUMBER&
    

        REPORT zfi_f140_operations.
    
        FORM get_vatnumber TABLES in_par  STRUCTURE itcsy
                                  out_par STRUCTURE itcsy.
    
          DATA: lv_co_code TYPE bukrs,
                lv_vat_no  TYPE stceg.
    
          READ TABLE in_par WITH KEY name = 'BKPF-BUKRS'.
          MOVE in_par-value TO lv_co_code.
    
          SELECT SINGLE stceg FROM t001
            INTO lv_vat_no WHERE bukrs = lv_co_code.
    
          out_par-name = 'VATNUMBER'.
          WRITE lv_vat_no TO out_par-value.
          CONDENSE out_par-value.
    
          MODIFY out_par INDEX 1.
    
    
    
        ENDFORM.               
    

    it is not working and i cannot work out why...

    i have not been ABAPing for very long but have had a go....

    any thoughts as to what i have done wrong?

    or point me where i should be looking? thank you!

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 18, 2010 at 02:19 PM

    You can create a subroutine pool and call a subroutine from a sap script.

    Without modifying the print program this is the only way to call a fm from sap script.

    But as you said you are not allowed to modify the print program, so there wont be any option provided to create a new program too i guess 😊

    Please search for 'sapscript subroutines' for more details

    Add comment
    10|10000 characters needed characters exceeded