Wednesday, December 22, 2010
When we call smartform function module, NO_OPEN and NO_CLOSE fields of SSFCTRLOP(Smart Forms: Control structure) structure need to be manipulated to display multiple records in Smart forms.


REPORT  ztest_smartform.
DATA:it_nfal        TYPE nfal       OCCURS 0 WITH HEADER LINE.
DATA:it_nfal_final  TYPE nfal       OCCURS 0 WITH HEADER LINE.
DATA:fm_name        TYPE rs38l_fnam.
DATA:wa_control_par TYPE ssfctrlop.
DATA:output_options  TYPE ssfcompop.
DATA:flag           TYPE c.
DATA:no_of_records  TYPE i.

"START-OF-SELECTION.

START-OF-SELECTION.
  "select data
  SELECT * FROM nfal INTO TABLE      it_nfal UP TO 10 ROWS WHERE einri = 'CGH'.
  SELECT * FROM nfal APPENDING TABLE it_nfal UP TO 10 ROWS WHERE einri = 'SGH'.
  SELECT * FROM nfal APPENDING TABLE it_nfal UP TO 10 ROWS WHERE einri = 'KKH'.
  SORT it_nfal BY einri.
  DESCRIBE TABLE it_nfal LINES no_of_records.
  LOOP AT it_nfal.
    AT FIRST.
      "Get Function module name for given smartform
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'ZTEST_SMARTFORM'
        IMPORTING
          fm_name  = fm_name.
    ENDAT.
    IF sy-tabix = no_of_records.
      flag = 'Y'.
    ENDIF.
    APPEND it_nfal TO it_nfal_final.
    AT END OF einri.
      "Set Control parameters
      IF flag = space.
        "Set the below one before we call smartform for the first time.
        wa_control_par-no_open  = space.
        wa_control_par-no_close = 'X'.
        flag = 'X'.
      ELSEIF flag = 'X'.
        "Set the below one for remaining calls to smartform
        wa_control_par-no_open  = 'X'.
        wa_control_par-no_close = 'X'.
      ELSEIF flag = 'Y'.
        "Set the below one for last call to smartform.
        wa_control_par-no_open  = 'X'.
        wa_control_par-no_close = space.
      ENDIF.
      "Call Smartform function module.
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = wa_control_par
        TABLES
          it_nfal            = it_nfal_final.
    ENDAT.
  ENDLOOP.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.