cancel
Showing results for 
Search instead for 
Did you mean: 

SAPscript: making internal table appear in output

Former Member
0 Kudos

Hi all,

I have an internal table (written in an external subroutine) that I want to be outputted onto the SAPscript form. I am trying to use loop....call write_form but I can't get it to work.

This is the code I have tried:


form get_components tables  intab  structure itcsy
                            outtab structure itcsy.

*---Get delivery doc number
  read table intab with key 'VBPLP-VBELN'.
  check sy-subrc = 0.
  gv_deldoc = intab-value.

*---Get item number
  read table intab with key 'VBPLP-POSNR'.
  check sy-subrc = 0.
  gv_posnr = intab-value.

*--do some data manipulation here to get data into it_comp...--*

  loop at it_comp into st_comp.
    call function 'WRITE_FORM'
     exporting
       element                        = 'DELPOS'
       function                       = 'APPEND'
       type                           = 'BODY'
       window                         = 'MAIN'
*     IMPORTING
*       PENDING_LINES                  =
*     EXCEPTIONS
*       ELEMENT                        = 1
*       FUNCTION                       = 2
*       TYPE                           = 3
*       UNOPENED                       = 4
*       UNSTARTED                      = 5
*       WINDOW                         = 6
*       BAD_PAGEFORMAT_FOR_PRINT       = 7
*       SPOOL_ERROR                    = 8
*       CODEPAGE                       = 9
*       OTHERS                         = 10
              .
    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

  endloop.

endform.                    "text

And in the SAPscript I have:


/E DELPOS
/: PERFORM GET_COMPONENTS IN PROGRAM ZPROGRAM
/: USING &VBPLP-VBELN&
/: USING &VBPLP-POSNR&
/: ENDPERFORM

DP ,,,,<H>&ST_COMP-MATNR&</>

This is what I thought will work based on looking around the forums - but it seems I am missing something. What is it?

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member186055
Active Participant
0 Kudos

Hi,

Debug Your subroutine pool program. check below statements, whether sy-subrc EQ 0 or not.

*---Get delivery doc number

read table intab with key 'VBPLP-VBELN'.

check sy-subrc = 0.

*---Get item number

read table intab with key 'VBPLP-POSNR'.

check sy-subrc = 0.

If Sy-subrc NE 0. then remaining block of code will not executed.

and also check internal table it_comp having data or not...

Regards,

Surya.

Former Member
0 Kudos

I have verified that table it_comp has data and it is not the 'checks' that are causing the issue.

Shiva, can you explain in more detail what you mean? I looked at the wiki but the solution it proposes I dont think will work for my case. Every time the subroutine is called, 1 sales order is passed into it, which can be tied to say 5 materials. Using the method from the wiki:

i.e.

wa_outtab-value = it_adrc-city.

MODIFY fp_it_outtab FROM wa_outtab INDEX sy-tabix.

This will only show one material in the sapscript when the internal table has 5 materials. I thought write_form could handle this but am still not successful

Former Member
0 Kudos

Instead of in an external program, I copied the print program and put the first section of code there.

In the SAPscript I was then able to call it directly (&wa_tab-matnr&) without the perform abc....

Edited by: pistols123 on Sep 10, 2011 12:23 AM

former_member230486
Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi

You need to pass the modified value back to perform as changing parameters.

You need to declare work areas for these ITAB.

If possible debug the code

And also I think WRITE_FORM is not required here.

Pass the changed parameters in ITAB fp_it_outtab to script.

Please look into below WIKI for more info:

http://wiki.sdn.sap.com/wiki/display/profile/ExternalSubroutinesinSAPScript

Shiva