Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

error when generating screen

hi,

this program i've done call smartform and in that i need two text boxes ..data should be enterd into the text boxes and smartforms printed..now for this text boxes iam using oo method..and this is my program

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

  • DATABASE TABLES *

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

TABLES: but000, t002.

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

  • INTERNAL TABLES *

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

DATA: gt_param LIKE zcrmtab_param OCCURS 0 WITH HEADER LINE.

DATA: gt_options TYPE ssfcompop,

gt_control TYPE ssfctrlop.

DATA: gt_but000 TYPE but000 OCCURS 0 WITH HEADER LINE,

gt_addresses TYPE adrc OCCURS 0 WITH HEADER LINE.

  • Table to hold address numbers

DATA: BEGIN OF gt_addr_numbers OCCURS 0,

partner LIKE but020-partner,

addrnumber LIKE but020-addrnumber,

END OF gt_addr_numbers.

DATA : gt_adrc_stores TYPE TABLE OF adrc.

DATA: gs_adrc_stores TYPE adrc.

  • Table to hold form name and language key

DATA: BEGIN OF gt_forms OCCURS 0,

form_name LIKE ppftsfprte-smartform,

langu TYPE langu,

END OF gt_forms.

DATA: gt_title TYPE TABLE OF tsad3t.

DATA : gs_title TYPE tsad3t.

DATA: BEGIN OF gt_country OCCURS 0,

langu TYPE spras,

country LIKE tsad3t-title_medi,

END OF gt_country.

DATA: gt_inv_lang LIKE gt_but000 OCCURS 0 WITH HEADER LINE.

DATA : remarks_con TYPE REF TO cl_gui_custom_container,

remarks TYPE REF TO cl_gui_textedit.

DATA: addnotes_con TYPE REF TO cl_gui_custom_container,

addnotes TYPE REF TO cl_gui_textedit.

DATA: text_tab LIKE STANDARD TABLE OF line,

text_wa LIKE line.

DATA text_tdline TYPE STANDARD TABLE OF tline WITH HEADER LINE.

DATA text_header TYPE thead.

TABLES: ttxit ,ttxid.

DATA line_length2 TYPE i VALUE 83.

DATA: ok_code TYPE sy-ucomm.

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

  • WORKING VARIABLES *

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

DATA: lv_langu TYPE c.

DATA: gv_addrnumber TYPE but020-addrnumber,

gv_amount TYPE zcrmdel_total_amount,

gv_func_mod_name TYPE rs38l_fnam,

gv_client_name TYPE char20.

DATA: gv_line(72) TYPE c.

DATA: gt_cond TYPE TABLE OF line WITH HEADER LINE.

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

****INCLUDES

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

INCLUDE zcfinc_maintain_cust_d.

INCLUDE zcfinc_maintaincust_f .

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

  • PARAMETERS / SELECT OPTIONS *

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

SELECTION-SCREEN BEGIN OF BLOCK s01 WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 3.

SELECTION-SCREEN COMMENT (20) text-002 FOR FIELD p_client.

SELECTION-SCREEN POSITION 27.

PARAMETERS p_client LIKE but000-partner OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 3.

SELECTION-SCREEN COMMENT (20) text-003 FOR FIELD s_cust.

SELECTION-SCREEN POSITION 24.

SELECT-OPTIONS: s_cust FOR but000-partner NO INTERVALS.

SELECTION-SCREEN END OF LINE.

*SELECTION-SCREEN BEGIN OF LINE.

*SELECTION-SCREEN POSITION 3.

*SELECTION-SCREEN COMMENT (20) text-004 FOR FIELD p_date.

*SELECTION-SCREEN POSITION 27.

*PARAMETERS p_date LIKE sy-datum. " OBLIGATORY.

*SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 3.

SELECTION-SCREEN COMMENT (20) text-009 FOR FIELD p_land.

SELECTION-SCREEN POSITION 27.

PARAMETERS p_land LIKE t005-land1 OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 3.

SELECTION-SCREEN COMMENT (20) text-011 FOR FIELD s_langu.

SELECTION-SCREEN POSITION 24.

SELECT-OPTIONS s_langu FOR t002-laiso NO INTERVALS OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK s01.

*SELECTION-SCREEN BEGIN OF BLOCK s02 WITH FRAME TITLE text-020.

*PARAMETER gencon RADIOBUTTON GROUP form.

*SELECTION-SCREEN END OF BLOCK s02 .

SELECTION-SCREEN BEGIN OF BLOCK s03 WITH FRAME TITLE text-003.

SELECTION-SCREEN SKIP.

PARAMETERS: p_print LIKE pri_params-pdest. " OBLIGATORY DEFAULT '*'.

SELECTION-SCREEN SKIP.

PARAMETERS: p_immed AS CHECKBOX DEFAULT ' ',

p_newsp AS CHECKBOX DEFAULT 'X',

p_delaft AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN END OF BLOCK s03.

SELECTION-SCREEN SKIP.

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

INITIALIZATION.

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

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

AT SELECTION-SCREEN.

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

  • Check that entered languages are valid

AT SELECTION-SCREEN ON s_langu.

SELECT SINGLE langu

INTO lv_langu

FROM tsad3t WHERE langu = s_langu-low(1).

IF sy-subrc <> 0.

MESSAGE w999 WITH 'INVALID LANGUAGE'.

ENDIF.

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

START-OF-SELECTION.

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

  • if gencon = 'X' .

PERFORM get_data.

CALL SCREEN 1000.

PERFORM print_forms.

  • ENDIF.

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

END-OF-SELECTION.

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

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

TOP-OF-PAGE.

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

DATA: w_col1 LIKE sy-linsz,

w_col2 LIKE sy-linsz,

w_len LIKE sy-linsz.

w_len = STRLEN( gv_client_name ).

w_col1 = ( sy-linsz - w_len ) / 2.

WRITE: / sy-repid.

WRITE AT w_col1 gv_client_name.

w_col2 = sy-linsz - 15.

WRITE: AT w_col2 text-006,

sy-pagno.

WRITE: / sy-datum DD/MM/YY.

w_len = STRLEN( sy-datum ).

w_col1 = ( sy-linsz - w_len ) / 2.

WRITE AT w_col1 sy-datum.

WRITE AT w_col2 sy-uzeit USING EDIT MASK '__:__:__'.

SKIP.

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

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

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

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

  • F O R M S

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

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

PERFORM get_parameters.

PERFORM get_customers.

PERFORM get_addresses.

PERFORM get_title.

PERFORM get_country.

ENDFORM. " get_data

----


*& Module STATUS_1000 OUTPUT

&----


  • text

----


MODULE status_1000 OUTPUT.

SET PF-STATUS 'MENU1'.

  • SET TITLEBAR 'xxx'.

IF remarks IS INITIAL.

  • Create obejct for custom container

CREATE OBJECT remarks_con

EXPORTING

container_name = 'REMARKS'.

  • Create obejct for the TextEditor control

CREATE OBJECT remarks

EXPORTING

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length2

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = remarks_con.

CALL METHOD remarks->set_toolbar_mode

EXPORTING

toolbar_mode = '0'.

CALL METHOD remarks->set_statusbar_mode

EXPORTING

statusbar_mode = '0'.

  • call method mremarks->set_font_fixed

  • exporting

  • font_fixed = '0'.

*

ENDIF.

IF addnotes IS INITIAL.

  • Create obejct for custom container

CREATE OBJECT addnotes_con

EXPORTING

container_name = 'ADDNOTES'.

  • Create obejct for the TextEditor control

CREATE OBJECT addnotes

EXPORTING

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length2

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = addnotes_con.

CALL METHOD addnotes->set_toolbar_mode

EXPORTING

toolbar_mode = '0'.

CALL METHOD addnotes->set_statusbar_mode

EXPORTING

statusbar_mode = '0'.

  • call method mremarks->set_font_fixed

  • exporting

  • font_fixed = '0'.

*

ENDIF.

ENDMODULE. " STATUS_1000 OUTPUT

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


MODULE user_command_1000 INPUT.

CASE ok_code.

WHEN 'SAVE'.

    • Remarks Editor

CLEAR : text_tab.

REFRESH: text_tab.

CALL METHOD remarks->get_text_as_stream

IMPORTING

text = text_tab.

IF NOT text_tab[] IS INITIAL.

text_header-tdobject = 'TEXT'.

text_header-tdid = 'EXRM'.

text_header-tdname = 'ENGREMARKS'.

text_header-tdspras = 'EN'.

LOOP AT text_tab INTO text_wa.

text_tdline-tdformat = '*'.

text_tdline-tdline = text_wa-line.

APPEND text_tdline.

ENDLOOP.

TRANSLATE text_wa-line TO UPPER CASE.

MOVE-CORRESPONDING text_header TO ttxit.

INSERT ttxit.

MOVE-CORRESPONDING text_header TO ttxid.

ttxid-tdshowname = 'x'.

INSERT ttxid.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = text_header

TABLES

lines = text_tdline

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

TRANSLATE text_tdline TO UPPER CASE.

IF sy-subrc = 0.

ENDIF.

  • CLEAR : TEXT_TDLINE,TEXT_TAB.

  • REFRESH: TEXT_TDLINE,TEXT_TAB.

*

ENDIF.

      • Additioanl notes editor

    • Remarks Editor

CLEAR : text_tab.

REFRESH: text_tab.

CALL METHOD addnotes->get_text_as_stream

IMPORTING

text = text_tab.

IF NOT text_tab[] IS INITIAL.

text_header-tdobject = 'TEXT'.

text_header-tdid = 'EXAD'.

text_header-tdname = 'ENGADDNOTES'.

text_header-tdspras = 'EN'.

LOOP AT text_tab INTO text_wa.

text_tdline-tdformat = '*'.

text_tdline-tdline = text_wa-line.

APPEND text_tdline.

ENDLOOP.

TRANSLATE text_wa-line TO UPPER CASE.

MOVE-CORRESPONDING text_header TO ttxit.

INSERT ttxit.

MOVE-CORRESPONDING text_header TO ttxid.

ttxid-tdshowname = 'x'.

INSERT ttxid.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = text_header

TABLES

lines = text_tdline

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

TRANSLATE text_tdline TO UPPER CASE.

IF sy-subrc = 0.

ENDIF.

ENDIF.

WHEN 'READ'.

**READ THE REMARKS TEXT THAT WAS SAVED BEFORE IF EXISTS

CLEAR: text_tab,text_tdline.

REFRESH: text_tab,text_tdline.

text_header-tdobject = 'TEXT'.

text_header-tdid = 'EXRM'.

text_header-tdname = 'ENGREMARKS'.

text_header-tdspras = 'E'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = text_header-tdid

language = text_header-tdspras

name = text_header-tdname

object = text_header-tdobject

TABLES

lines = text_tdline

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc <> 0.

ELSE.

LOOP AT text_tdline.

text_wa-line = text_tdline-tdline.

APPEND text_wa TO text_tab.

TRANSLATE text_wa TO UPPER CASE.

ENDLOOP.

ENDIF.

CALL METHOD remarks->set_text_as_stream

EXPORTING

text = text_tab.

CLEAR : text_tdline,text_tab.

REFRESH: text_tab,text_tdline.

text_header-tdobject = 'TEXT'.

text_header-tdid = 'EXAD'.

text_header-tdname = 'ENGADDNOTES'.

text_header-tdspras = 'E'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = text_header-tdid

language = text_header-tdspras

name = text_header-tdname

object = text_header-tdobject

TABLES

lines = text_tdline

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc <> 0.

ELSE.

LOOP AT text_tdline.

IF sy-tabix = 1.

CLEAR text_tdline.

ENDIF.

text_wa-line = text_tdline-tdline.

APPEND text_wa TO text_tab.

TRANSLATE text_wa TO UPPER CASE.

ENDLOOP.

ENDIF.

CALL METHOD addnotes->set_text_as_stream

EXPORTING

text = text_tab.

WHEN 'CLEAR'.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_1000 INPUT

&----


*& Form print_forms

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM print_forms .

PERFORM set_print_params.

*Copy all customers to invalid lang table

gt_inv_lang[] = gt_but000[].

SORT gt_inv_lang BY partner.

LOOP AT gt_forms.

  • get FM name

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = gt_forms-form_name

IMPORTING

fm_name = gv_func_mod_name.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION gv_func_mod_name

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

gv_addresses = gv_address

gt_but000 = gt_but000

gs_title = gs_title

gs_adrc_stores = gs_adrc_stores

gv_amount = gv_amount

text_tab = text_tab.

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

  • EXCEPTIONS

  • FORMATTING_ERROR = 1

  • INTERNAL_ERROR = 2

  • SEND_ERROR = 3

  • USER_CANCELED = 4

  • OTHERS = 5

.

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. " print_forms

&----


*& Form get_customers

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_customers .

SELECT *

INTO

TABLE gt_but000

FROM but000

WHERE partner IN s_cust

AND zzclientnumb = p_client.

IF gt_but000[] IS INITIAL.

MESSAGE i999 WITH 'No Data selected for forms'.

ENDIF.

ENDFORM. " get_customers

&----


*& Form get_addresses

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_addresses .

DATA: lt_addresses TYPE TABLE OF bapibus1006_addresses WITH HEADER LINE.

LOOP AT gt_but000.

    • First get address guids

PERFORM get_address_guids USING gt_but000-partner.

lt_addresses-addressguid = gv_soldtoaddrguid.

    • address details.

PERFORM address_get_details USING gt_but000-partner

lt_addresses-addressguid.

ENDLOOP.

IF lv_langu = 'S'

AND p_client = '0004000181' .

    • Need to get address numbers for store addresses

SELECT partner

addrnumber

FROM but020

INTO TABLE

gt_addr_numbers

WHERE partner = gt_but000-zzilgstorenu.

LOOP AT gt_addr_numbers.

SELECT SINGLE *

INTO gs_adrc_stores

FROM adrc

WHERE addrnumber = gt_addr_numbers-addrnumber.

ENDLOOP.

ENDIF.

ENDFORM. " get_addresses

&----


*& Form get_parameters

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_parameters.

DATA: lv_param.

RANGES: r_param FOR zcrmtab_param-zparameter.

SELECT *

INTO TABLE gt_param

FROM zcrmtab_param

WHERE parentid = sy-repid

AND identifier = p_client.

  • IF gencon = 'X'.

LOOP AT s_langu.

CONCATENATE 'GENCON_LETTER' s_langu-low INTO r_param-low

SEPARATED BY '_'.

APPEND r_param.

ENDLOOP.

  • ENDIF.

  • Get the forms that need to be printed and build up a table

  • with form name and language key

LOOP AT r_param.

READ TABLE gt_param WITH KEY zparameter = r_param-low.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Parameter' r_param-low 'not found'.

ELSE.

    • Build up condition

  • IF gencon = 'X'.

CONCATENATE 'laiso = ''' r_param-low+14 '''' INTO gv_line.

APPEND gv_line TO gt_cond.

  • ENDIF.

gt_forms-form_name = gt_param-zvalue.

SELECT SINGLE spras

INTO gt_forms-langu

FROM t002

WHERE (gt_cond).

APPEND gt_forms.

ENDIF.

ENDLOOP.

ENDFORM. " get_parameters

&----


*& Form set_print_params

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM set_print_params .

gt_options-tddelete = p_delaft. "Delete after printing

gt_options-tddest = p_print. "Printer

IF p_print IS INITIAL.

SELECT SINGLE spld INTO gt_options-tddest

FROM usr01

WHERE bname = sy-uname.

ENDIF.

IF gt_options-tddest IS INITIAL.

MESSAGE a999 WITH 'No printer defined'.

ENDIF.

gt_options-tdnewid = p_newsp. "New Spool Request

gt_options-tdimmed = p_immed. "Print Immediateley

gt_control-no_dialog = 'X'. "Don't display Dialogue box

ENDFORM. " set_print_params

&----


*& Form get_title

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_title .

SELECT SINGLE *

INTO gs_title

FROM tsad3t

WHERE langu = sy-langu

AND title = gt_but000-title.

ENDFORM. " get_title

&----


*& Form get_country

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_country .

SELECT spras landx

INTO TABLE gt_country

FROM t005t

WHERE land1 = gv_address-country.

endform.

when iam executing this..gettin an error < error when generating the screen>

plz advise..

Former Member
Not what you were looking for? View more on this topic or Ask a question