Call sap smartforms from ALV report :
Code :
REPORT ZMM_PO_PRINT_SF.
tables : ekko.
types : begin of tp_list,
sel,
ebeln type ekko-ebeln,
aedat type ekko-aedat,
lifnr type ekko-lifnr,
end of tp_list.
data : gt_list type STANDARD TABLE OF tp_list,
gs_list type tp_list.
data : gt_fcat type SLIS_T_FIELDCAT_ALV,
gs_fcat like LINE OF gt_fcat,
gs_layout type SLIS_LAYOUT_ALV,
gs_variant type DISVARIANT,
gv_cnt type i.
data : FM_NAME TYPE RS38L_FNAM,
CONTROL_PARAMETERS TYPE SSFCTRLOP,
OUTPUT_OPTIONS TYPE SSFCOMPOP.
SELECTION-SCREEN begin of BLOCK b1 WITH FRAME TITLE text-001.
select-OPTIONS : s_ebeln for ekko-ebeln.
SELECTION-SCREEN end of BLOCK b1.
START-OF-SELECTION.
perform get_data.
perform display_data.
end-of-SELECTION.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
select ebeln aedat lifnr from ekko into CORRESPONDING FIELDS OF TABLE gt_list
WHERE ebeln in s_ebeln.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
clear : gv_cnt, gt_fcat[], gs_fcat.
gs_layout-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-BOX_FIELDNAME = 'SEL'.
GS_VARIANT-report = sy-repid.
gv_cnt = gv_cnt + 1.
gs_fcat-COL_POS = gv_cnt.
gs_fcat-FIELDNAME = 'EBELN'.
gs_fcat-SELTEXT_M = 'PO Number'.
gs_fcat-HOTSPOT = 'X'.
append gs_fcat to gt_fcat.
clear : gs_fcat.
gv_cnt = gv_cnt + 1.
gs_fcat-COL_POS = gv_cnt.
gs_fcat-FIELDNAME = 'AEDAT'.
gs_fcat-SELTEXT_M = 'PO Date'.
append gs_fcat to gt_fcat.
clear : gs_fcat.
gv_cnt = gv_cnt + 1.
gs_fcat-COL_POS = gv_cnt.
gs_fcat-FIELDNAME = 'LIFNR'.
gs_fcat-SELTEXT_M = 'Vendor ID.'.
append gs_fcat to gt_fcat.
clear : gs_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = gt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = GS_VARIANT
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = gt_list
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
clear : gs_list.
read TABLE gt_list into gs_list INDEX RS_SELFIELD-TABINDEX.
if gs_list-ebeln is NOT INITIAL.
perform call_sf.
endif.
ENDCASE.
clear : gs_list, sy-ucomm.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALL_SF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CALL_SF.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZDEMO_PO1'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CONTROL_PARAMETERS-PREVIEW = 'X'.
CONTROL_PARAMETERS-NO_DIALOG = 'X'.
OUTPUT_OPTIONS-TDDEST = 'LP01'.
CALL FUNCTION FM_NAME "'/1BCDWB/SF00000264'
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
OUTPUT_OPTIONS = OUTPUT_OPTIONS
USER_SETTINGS = 'X'
IP_EBELN = gs_list-ebeln
* 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.
* Implement suitable error handling here
ENDIF.
ENDFORM.
4 Comments
hi jafar u select one purchase document no and show the output in smartform.
ReplyDeletehow to select multiple purchase document no and show the output in smartform plz give the example.ur video is very good.
Hi,
DeleteKindly refer my post and video for similar requirement.
https://zafarkarnalkar.blogspot.com/2020/04/sap-abap-smartforms-output-of-loop-in.html?m=0
Hai sir please post videos on ooabap concept
ReplyDeleteThank alot sir.
ReplyDelete