Skip to Content
avatar image
Former Member

SAP Sscript External Subroutine Problem

Hi ,

i am facing One Problem in PO Print. i am using SAP Script for PO Print. I am using an External Subroutine company_excise_data in my SAP Script to fecth some data.

The logic is working fine. the subroutine is getting exectued. but I am not able to pass back the data to the script.

I have dont the complete things as:

Firstly i have declared a variable in my script as

/: DEFINE &J_1IMOCOMP-J_1IEXCD& = ''.

Then I define a subroutine in script as

/: PERFORM COMPANY_EXCISE_DATA IN PROGRAM ZPO_PRINT_MISC

/: USING &EKPO-WERKS& CHANGING &J_1IMOCOMP-J_1IEXCD&

/: ENDPERFORM.

then i define subrotine in my the program ZPO_PRINT_MISC as:

REPORT ZPO_PRINT_MISC.

tables: J_1IMOCOMP.

DATA : BEGIN OF in_par OCCURS 10.

INCLUDE STRUCTURE itcsy.

DATA : END OF in_par.

DATA : BEGIN OF out_par OCCURS 0.

INCLUDE STRUCTURE itcsy.

DATA : END OF out_par.

DATA: TOBJD1 TYPE PPVAR-TOBJD,

TOBJD2 TYPE PPVAR-TOBJD.

form company_excise_data TABLES input output.

in_par[] = input[].

out_par[] = output[].

READ TABLE in_par INDEX 1.

MOVE in_par-value TO TOBJD1.

READ TABLE in_par INDEX 2.

MOVE in_par-value TO TOBJD2.

select single * from J_1IMOCOMP where bukrs = 'SEML'

and werks = tobjd2.

out_par-name = 'J_1IMOCOMP-J_1IEXCD'.

MOVE J_1IMOCOMP-J_1IEXCD TO out_par-value.

append out_par.

output[] = out_par[].

endform.

Now The problem is that, still I am not getting the value back into variable &J_1IMOCOMP-J_1IEXCD& of my SAP Scipt.

Kindly Halp me out.

<REMOVED BY MODERATOR>

Regards,

Varun Sanghi

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 3:31 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 20, 2008 at 03:24 AM

    This may help you to close your thread.

    /: DEFINE &J_1IMOCOMP-J_1IEXCD& = ''.

    Then I define a subroutine in script as

    /: PERFORM COMPANY_EXCISE_DATA IN PROGRAM ZPO_PRINT_MISC

    /: USING &EKPO-WERKS&

    /: CHANGING &J_1IMOCOMP-J_1IEXCD&

    /: ENDPERFORM.

    then i define subrotine in my the program ZPO_PRINT_MISC as:

    REPORT ZPO_PRINT_MISC.

    tables: J_1IMOCOMP.

    DATA : BEGIN OF in_par OCCURS 10.

    INCLUDE STRUCTURE itcsy.

    DATA : END OF in_par.

    DATA : BEGIN OF out_par OCCURS 0.

    INCLUDE STRUCTURE itcsy.

    DATA : END OF out_par.

    DATA: TOBJD1 TYPE PPVAR-TOBJD,

    TOBJD2 TYPE PPVAR-TOBJD.

    form company_excise_data TABLES input output.

    in_par] = input[.

    out_par] = output[.

    READ TABLE in_par INDEX 1.

    MOVE in_par-value TO TOBJD1.

    READ TABLE in_par INDEX 2.

    MOVE in_par-value TO TOBJD2.

    select single * from J_1IMOCOMP where bukrs = 'SEML'

    and werks = tobjd2.

    out_par-name = 'J_1IMOCOMP-J_1IEXCD'.

    MOVE J_1IMOCOMP-J_1IEXCD TO out_par-value.

    MODIFY OUT_PAR INDEX SY-TABIX.

    endform.

    Regards,

    Sairam

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 19, 2008 at 11:53 AM

    Hi,

    Only one small change needed. Your table out_par already contains one row with key J_1IMOCOMP-J_1IEXCD, so in your subroutine your code;

    out_par-name = 'J_1IMOCOMP-J_1IEXCD'.
    MOVE J_1IMOCOMP-J_1IEXCD TO out_par-value.
    append out_par.
    

    Doesn't need an append, this is resulting in two records in out_par. Replace it with

    READ TABLE OUT_PAR WITH KEY 'J_1IMOCOMP-J_1IEXCD'.
    MOVE J_1IMOCOMP-J_1IEXCD TO out_par-value.
    MODIFY OUT_PAR INDEX SY-TABIX.
    

    Regards,

    Nick

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 19, 2008 at 01:15 PM

    U have to use ITCSY structure to write external subroutines in Scripts

    Add comment
    10|10000 characters needed characters exceeded