cancel
Showing results for 
Search instead for 
Did you mean: 

Combining 2 Programs into 1

Former Member
0 Kudos

Hi,

I have 2 report programs that I want to combine into 1.

Basically , I have created my own version of transaction SP01 ( business requirement ) , which displays spool information, but does not display the spool on the screen. I also have another program, which displays information in pdf on the screen, I know there are functions avilable to convert spools into .pdf format.

My second program has a screen representation, and what I tried initally, create the screen, paste the code from the report into a form , and then call the form.

But I keep getting the error message:

Incorrect nesting: Before the statement "MODULE", the structure

introduced by "FORM" must be concluded by "ENDFORM"

the code for my report , which displays the pdf file is shown below;

REPORT viewing_demo MESSAGE-ID demoofficeintegratio.

TYPES: BEGIN OF document_descr,

document_name(40), document_id(64),

END OF document_descr.

TYPES: document_list TYPE document_descr OCCURS 0.

TYPES: t_url LIKE bapiuri-uri.

DATA: bds_instance TYPE REF TO cl_bds_document_set,

url_lifetime TYPE sbdst_url_lifetime.

DATA: type(128) TYPE c, subtype(128) TYPE c.

DATA: delimiter(1) TYPE c VALUE'/'.

DATA: size TYPE i.

DATA: content_table TYPE sbdst_content.

DATA: mycontent_table TYPE sbdst_content. "Sanjay Internal Table

DATA: viewer TYPE REF TO i_oi_document_viewer,

my_container TYPE REF TO cl_gui_custom_container.

DATA: fcode LIKE sy-ucomm,

edurl(2048).

DATA: inplace(1) VALUE space, via_url(1) VALUE space.

************************************************************

************************************************************

DATA: p_fname LIKE rlgrap-filename VALUE

'c:\a.pdf', v_ans.

*************************************************************

*************************************************************

SET SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'TESTVIEWER'.

SET TITLEBAR '001' WITH delimiter.

  • set titlebar 'Purchase Order Archive Documen'.

IF my_container IS INITIAL.

CREATE OBJECT my_container

EXPORTING

container_name = 'VIEW'

EXCEPTIONS

OTHERS = 1.

CASE sy-subrc.

WHEN 0.

WHEN OTHERS.

RAISE cntl_error.

ENDCASE.

ENDIF.

IF viewer IS INITIAL.

CALL METHOD c_oi_container_control_creator=>get_document_viewer

IMPORTING

viewer = viewer

EXCEPTIONS

unsupported_platform = 1.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

CALL METHOD viewer->init_viewer

EXPORTING

parent = my_container

EXCEPTIONS

cntl_error = 1

cntl_install_error = 2

dp_install_error = 3

dp_error = 4.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

ENDIF.

CLEAR edurl.

******************************************************************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\A.PDF'

filetype = 'BIN'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = mycontent_table

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

************************************************************************

***********************

************************************************************************

***********************

type = 'application'.

subtype = 'PDF'.

inplace = 'X'.

CALL METHOD viewer->view_document_from_table

EXPORTING

type = type

subtype = subtype

size = 72704

show_inplace = inplace

CHANGING

document_table = mycontent_table

EXCEPTIONS

cntl_error = 1

not_initialized = 2

dp_error_general = 3

invalid_parameter = 4

dp_invalid_parameter = 5.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

ENDMODULE. "STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


MODULE user_command_0100 INPUT.

CASE fcode.

WHEN 'BACK'.

IF NOT viewer IS INITIAL.

CALL METHOD viewer->destroy_viewer

EXCEPTIONS

not_initialized = 1

free_failed = 2.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

FREE viewer.

ENDIF.

IF NOT my_container IS INITIAL.

CALL METHOD my_container->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE i009.

ENDIF.

FREE my_container.

ENDIF.

LEAVE PROGRAM.

WHEN 'CLOSE'.

CALL METHOD viewer->close_document

EXCEPTIONS

cntl_error = 1

not_initialized = 2.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

IF NOT viewer IS INITIAL.

CALL METHOD viewer->destroy_viewer

EXCEPTIONS

not_initialized = 1

free_failed = 2.

IF sy-subrc NE 0.

MESSAGE i009.

ENDIF.

FREE viewer.

ENDIF.

IF NOT my_container IS INITIAL.

CALL METHOD my_container->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE i009.

ENDIF.

FREE my_container.

ENDIF.

LEAVE PROGRAM.

ENDCASE.

CLEAR fcode.

ENDMODULE. "USER_COMMAND_0100 INPUT

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can't have a module inside of a FORM. You must put the modules outside of the FORM, maybe in an include program. Are you added this into a module pool? or just another report program>

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

its just another report program, which has a selection screen, display spool information, and then I want to display the contents of the spool, when the user clicks a particular spool , from a list, or they check a number of them.

I think I'm getting confused how I should try and integrate this code, or if there is a way to call it from the main program, with parameters.

Thanks

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You CAN NOT have a MODULE in a FORM. Remove the modules from inside the FORM. You can call this form to kick off your screen no problem, just remove the MODULE/ENDMODULE outside of the FORM/ENDFORM. Put them at the end of your program source code.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, it would be easier to just call your other report, but you mentioned that you want to consolidate. Nothing wrong with that.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

"I think I'm getting confused how I should try and integrate this code, or if there is a way to call it from the main program, with parameters"

Use SUBMIT <Program Name> Technique and call your second report from the main program. Then to pass parameters, you have to convert some your data variables in the second report into parameters with defaults so that they can also be filled from the main program while callling it using SUBMIT.

Check keyword documentation for SUBMIT if you have further doubts.

Sri

Former Member
0 Kudos

Hi Rich,

thats pretty much solved it. Many thanks for that, the only thing its not doing now, is showing the new screen, until I press the back button, any ideas?

Thanks again.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Can you please try changing the SET SCREEN statement to CALL SCREEN .

Please remember to award points for helpful answers. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

call screen brings up the screen, but none of the data that should be there is, perhaps the classes which initilise it have not done so at this stage. If I use set screen , the new screen is not displayed until I press the back button on the current screen.

Not really sure how to get round this one, I could post it as a separate question if that helps.

Thanks

Answers (1)

Answers (1)

ChristianFi
Active Participant
0 Kudos

That is because you can not nest a form in a module. Make sure that you paste the forms outside of your module declaration (you can call the forms though. Make alse sure that you do not post the list events top-of-page, start-of-selection.....

Christian

Former Member
0 Kudos

Hi,

not sure what your answer means, do you mean I can not nest a module in a form?

And if I wanted this routine available from different events how do I do this? Is it better to just try and call the report from the first one, and can I pass parameters to it?

Thanks