Sap final reports

alv reports in sap abap programming language
*----------------------------------------------------------------------*
*  Report  ZFINAL_REPORTS                                             *
*                                                                      *
*----------------------------------------------------------------------*
*                                                                      *
*   Author..............    :   rohini kumar                           *
*   Creation Date.......    :   27/07/2017                             *
*   Requested by........    :                                          *
*   Reference document..    : CR2369514 e.g. Func. and Tech. spec      *
*   Project.............    :                                          *
*   Description.........    : puraches order forms                     *
*----------------------------------------------------------------------*
* Modification History :                                               *
*                                                                      *
*   Author      Date    Correction #   Purpose/Reason                  *
*  --------   --------  ------------   --------------------------------*
*                        CR45433        Add additional Fields          *
*  --------   --------  ------------   --------------------------------*
* top include for global data declaration
INCLUDE zfinal_reports_top                      .    " global Data

* sel include for selction of the reprots
INCLUDE zfinal_reports_sel.

* form include for subroutine and funcation module
INCLUDE zfinal_reports_f01                      .  " FORM-Routines

* Load of the program this evern trigger before the initialization when load the menu and screen
LOAD-OF-PROGRAM.

* initialization this event trigger the after the load of the program
INITIALIZATION.
  PERFORM clear_data.

* at selecation screen evenet for perform some operation on selecation screen
AT SELECTION-SCREEN.

* at selection - screen ouput this event triggere the foramte the screen
AT SELECTION-SCREEN OUTPUT.
* formate the screen as per the user requirments
  PERFORM formate_screen.

* validation on the screen ebeln check the low valuws
AT SELECTION-SCREEN ON s_ebeln.
  PERFORM validation.
* Provide search help on Local PC
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM f_file_shelp.

* start of the seleccation event
START-OF-SELECTION.
* fetach the data in database using perform get_data
  PERFORM get_data.

END-OF-SELECTION.
* populating the fields catalog in alv reports
  PERFORM populate_fact.
  PERFORM layout_alv.  " USING ALV REPORTS TO ADD BOX
* alv event for using
  PERFORM pop_event.

  IF alv = 'X'.
    PERFORM f_display_ekkpo_ekpo.
  ELSEIF downlode EQ 'X'.
    IF p_dwnd EQ 'X'.
* Display OR Download data

      PERFORM f_download.
    ELSE.
      PERFORM f_upload.
    ENDIF.
  ENDIF.

Top include:
*&---------------------------------------------------------------------*
*& Include ZFINAL_REPORTS_TOP                                Report ZFINAL_REPORTS
*&
*&---------------------------------------------------------------------*

REPORT   zfinal_reports NO STANDARD PAGE HEADING MESSAGE-ID zmsg.
*DATA: P_EBELN TYPE EKKO-EBELN,
*      P_EKORG TYPE EKKO-EKORG.

TYPE-POOLS : slis .

* global data declration in table ekko and ekpo
TYPES : BEGIN OF ZGT_EKKO_EKPO,
         ebeln  TYPE  ebeln,
          lifnr TYPE  elifn,
          ekorg TYPE  ekorg,
          ebelp TYPE  ebelp,
          matnr TYPE  matnr,
          menge TYPE  bstmg,
          netpr TYPE  bprei,
          netwr TYPE  bwert,
       END OF ZGT_EKKO_EKPO.

*
TYPES : BEGIN OF ty_lfa1,
       lifnr type elifn,
        land1 TYPE  land1_gp,
        name1 TYPE  name1_gp,
        pstlz TYPE  pstlz,
        adrnr TYPE  adrnr,
        END OF ty_lfa1.
* final type for table ekko and ekpo
TYPES: BEGIN OF typ_final,
        ebeln TYPE  ebeln,
        lifnr TYPE  elifn,
        ekorg TYPE  ekorg,
        ebelp TYPE  ebelp,
        matnr TYPE  matnr,
        menge TYPE  bstmg,
        netpr TYPE  bprei,
        netwr TYPE  bwert,
        land1 TYPE  land1_gp,
        name1 TYPE  name1_gp,
        pstlz TYPE  pstlz,
        adrnr TYPE  adrnr,

* 1. Add an additional single char field
      box,
   END OF typ_final.

DATA: gt_ekko_ekpo TYPE STANDARD TABLE OF ZGT_EKKO_EKPO,
      gt_lfa1   TYPE STANDARD TABLE OF ZGT_LFA11,
      gt_final  TYPE STANDARD TABLE OF typ_final.

DATA: gs_ekko_ekpo TYPE ZGT_EKKO_EKPO,
      gs_lfa1   TYPE ZGT_LFA11,
      gs_final  TYPE typ_final.
* FIELD CATALOG IN ALV REPORTS
DATA: gt_fact   TYPE slis_t_fieldcat_alv,
      gs_fact   TYPE slis_fieldcat_alv,
      gt_header TYPE slis_t_listheader,
      gs_header TYPE slis_listheader,
      gs_layout TYPE slis_layout_alv. "ADDTING LAYOUT IN ALV REPORTS

* GETTING  SUBTOAL.
DATA: gt_sort TYPE slis_t_sortinfo_alv,
      gs_sort TYPE slis_sortinfo_alv.
*POPULATING EVENT AND SET CUSTOM MENU STATUS IN SAP ABAP
DATA:
      gt_events TYPE slis_t_event,
      gs_events TYPE slis_alv_event. " LIKE LINE OF gt_events

* DECLRATION DATA TYPE TO CALL SMARTORMS
DATA: formname  TYPE  tdsfname,                            "#EC NEEDED
      fm_name1 TYPE  rs38l_fnam,
      ls_ctrlop TYPE ssfctrlop,
      ls_compop TYPE ssfcompop.

CONSTANTS:gc_x TYPE c VALUE 'X'.

* sel include:
*selecation screen you puraches order form
PARAMETERS: alv RADIOBUTTON GROUP g2 USER-COMMAND u MODIF ID m DEFAULT 'X' ,
            downlode RADIOBUTTON GROUP g2 MODIF ID m .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*SELECT-OPTIONS: s_ebeln FOR P_EBELN  MODIF ID m1,
*                s_ekorg FOR P_EKORG NO INTERVALS MODIF ID m1.
SELECT-OPTIONS s_ebeln FOR gs_ekko_ekpo-ebeln MODIF ID m1.
SELECTION-SCREEN END OF BLOCK b1.
* selection screen for downlode and uplode fetures
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS:p_file TYPE dynpread-fieldname  MODIF ID m3.
PARAMETERS:p_dwnd RADIOBUTTON GROUP g1 MODIF ID m3,
           p_upld RADIOBUTTON GROUP g1 MODIF ID m3.

SELECTION-SCREEN END OF BLOCK b2.

from include :

*&---------------------------------------------------------------------*
*&  Include           ZFINAL_REPORTS_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  FORMATE_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM formate_screen .
* foramtes the screen as per the user requimets
  IF alv = 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'M2' OR screen-group1 = 'M3'.
        screen-active = 0 .
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
  IF downlode = 'X'.

    LOOP AT SCREEN.
      IF screen-group1 = 'M1'.
        screen-active = 0 .
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " FORMATE_SCREEN

*&---------------------------------------------------------------------*
*&  Include           ZPURACHES_ORDER_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  CLEAR_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM clear_data .
* clear the data of inter table and output
  CLEAR: gs_ekko_ekpo,
         gs_lfa1,
         gs_final.

  REFRESH : gt_ekko_ekpo,
           gt_lfa1,
           gt_final.

ENDFORM.                    " CLEAR_DATA
*&---------------------------------------------------------------------*
*&      Form  VALIDATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM validation .
* LOcal data declarations
  TYPES:BEGIN OF ltyp_ebeln,
         ebeln TYPE ekko-ebeln,
        END OF ltyp_ebeln.
  DATA:lt_ebeln TYPE STANDARD TABLE OF ltyp_ebeln.

  REFRESH lt_ebeln.

  SELECT ebeln
       FROM ekko "vbuk"likp
       INTO TABLE lt_ebeln
       WHERE ebeln IN s_ebeln.
  IF sy-subrc <> 0.
    MESSAGE e001 WITH text-e05.
  ENDIF.

ENDFORM.                    " VALIDATION
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
* fetach the data in selection screen output
  SELECT  a~ebeln
          a~lifnr
          a~ekorg

          b~ebelp
          b~matnr
          b~menge
          b~netpr
          b~netwr

    INTO TABLE gt_ekko_ekpo
    FROM ekko AS a INNER JOIN ekpo AS b
    ON a~ebeln = b~ebeln
    WHERE a~ebeln IN  s_ebeln.

  SELECT
      lifnr
      land1
      name1
      pstlz
      adrnr
      FROM lfa1
    INTO TABLE gt_lfa1
     FOR ALL ENTRIES IN gt_ekko_ekpo
     WHERE lifnr = gt_ekko_ekpo-lifnr.

* move the data of final internal table in
  LOOP AT  gt_ekko_ekpo INTO gs_ekko_ekpo.
    MOVE: gs_ekko_ekpo-ebeln TO gs_final-ebeln,
          gs_ekko_ekpo-lifnr TO gs_final-lifnr,
          gs_ekko_ekpo-ekorg TO gs_final-ekorg,
          gs_ekko_ekpo-ebelp TO  gs_final-ebelp,
          gs_ekko_ekpo-matnr TO  gs_final-matnr,
         gs_ekko_ekpo-menge TO  gs_final-menge,
          gs_ekko_ekpo-netpr TO  gs_final-netpr,
          gs_ekko_ekpo-netwr TO  gs_final-netwr.

    READ TABLE gt_lfa1 INTO gs_lfa1 WITH KEY lifnr = gs_ekko_ekpo-lifnr.
*
    MOVE:   gs_lfa1-lifnr TO gs_final-lifnr,
             gs_lfa1-land1 TO gs_final-land1,
             gs_lfa1-name1 TO gs_final-name1,
             gs_lfa1-pstlz TO gs_final-pstlz,
             gs_lfa1-adrnr TO gs_final-adrnr.


    APPEND gs_final TO gt_final.
  ENDLOOP.
*    ENDIF.
*  ENDIF.

ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  POPULATE_FACT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
* populating the data in final table to fieldcatalog using
FORM populate_fact .
  gs_fact-col_pos = '0'.
  gs_fact-fieldname = 'EBELN'.
  gs_fact-hotspot = 'X'.
  gs_fact-tabname = 'GT_FINAL'.
  gs_fact-seltext_m = 'PURACHES DOCU'.

  APPEND gs_fact TO gt_fact.
  CLEAR gs_fact.

  PERFORM f_fieldcat USING text-p02 text-f02 text-t02 text-s02.
  PERFORM f_fieldcat USING text-p03 text-f03 text-t02 text-s03.
  PERFORM f_fieldcat USING text-p04 text-f04 text-t02 text-s04.
*  PERFORM f_fieldcat USING text-p05 text-f05 text-t02 text-s05.

* getting toal in alv reports
  gs_fact-col_pos = '4'.
  gs_fact-fieldname = 'NETPR'.
  gs_fact-tabname = 'GT_FINAL'.
  gs_fact-seltext_m = 'PRICE'.
  gs_fact-do_sum = 'X'.
  gs_fact-edit = 'X'.
  APPEND gs_fact TO gt_fact.
  CLEAR gs_fact.

* GETTING SUBTOAL IN SAP ABAP PROGRAMMING
  gs_sort-fieldname = 'EBELN'.
  gs_sort-up       = 'X'.
  gs_sort-subtot   = 'X'.
  gs_sort-tabname = 'GT_FINAL'.
  APPEND gs_sort TO gt_sort.

ENDFORM.                    " POPULATE_FACT
*&---------------------------------------------------------------------*
*&      Form  F_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TEXT_P02  text
*      -->P_TEXT_F02  text
*      -->P_TEXT_T02  text
*      -->P_TEXT_S02  text
*----------------------------------------------------------------------*
* reuse in alv reprots
FORM f_fieldcat  USING    p_pos                         "#EC PF_NO_TYPE
                          p_field
                          p_table
                          p_shorttext.
  gs_fact-col_pos = p_pos.
  gs_fact-fieldname = p_field.
  gs_fact-tabname = p_table.
  gs_fact-seltext_m  = p_shorttext.
  APPEND gs_fact TO gt_fact.
  CLEAR gs_fact.

ENDFORM.                    " F_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  GET_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ITEM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->UCOMM      text
*      -->SELFIELD   text
*----------------------------------------------------------------------*
* display item from using to pupulating the click funcatinalties in sap abap programming
FORM display_item USING ucomm TYPE sy-ucomm
                   selfield TYPE slis_selfield.             "#EC CALLED
DATA:lt_final TYPE STANDARD TABLE OF typ_final.
  CASE ucomm.
    BREAK-POINT.
    WHEN '&IC1'.
      READ TABLE gt_ekko_ekpo INTO gs_ekko_ekpo INDEX selfield-tabindex.
      DATA: l_varial(10) TYPE c.
      MOVE: gs_ekko_ekpo-ebeln TO l_varial.
      SET PARAMETER ID 'BES' FIELD l_varial.
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    WHEN 'BUTT1'.
* Capture Seelcted Rows
      lt_final = gt_final.
* Delete Non selected Rows
      DELETE lt_final WHERE box <> gc_x.
      PERFORM f_display_data TABLES lt_final.
    WHEN 'SMARTFORMS'.
     READ TABLE gt_ekko_ekpo INTO gs_ekko_ekpo INDEX selfield-tabindex.
    delete gt_ekko_ekpo where ebeln <> gs_ekko_ekpo-ebeln.
* call the smartforms thro alv outpout
  DATA
      fm_name1 TYPE  rs38l_fnam.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = 'ZPURACHES_ORDER1'
*     VARIANT            = ' '
*     DIRECT_CALL        = ' '
    IMPORTING
      fm_name            = fm_name1
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  ls_ctrlop-no_dialog = 'X'.
  ls_ctrlop-preview = 'X'.
  ls_compop-tddest = 'LP01'.
*  BREAK-POINT.
CALL FUNCTION FM_NAME1
  EXPORTING
   CONTROL_PARAMETERS         =   ls_ctrlop
   OUTPUT_OPTIONS             = ls_compop
   USER_SETTINGS              = 'X'
    gt_ekko_ekpo1              = gt_ekko_ekpo
    GT_LFA1                    = gt_LFA1
* 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.



  ENDCASE.
ENDFORM.                    "DISPLAY_ITEM
*&---------------------------------------------------------------------*
*&      Form  POP_EVENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
* this from use to print the header and footer in alv reports
FORM pop_event .
  gs_events-name = 'TOP_OF_PAGE'.
  gs_events-form = 'F_TOP_OF_PAGE'.
  APPEND gs_events TO gt_events.

  gs_events-name = 'PF_STATUS_SET'.
  gs_events-form = 'F_PF_STATUS_SET'.
  APPEND gs_events TO gt_events.

ENDFORM.                    " POP_EVENT

*&---------------------------------------------------------------------*
*&      Form  f_pf_status_set
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PT_EXTAB   text
*----------------------------------------------------------------------*
FORM f_pf_status_set USING pt_extab TYPE slis_t_extab.      "#EC CALLED
* Local data varaibles
  DATA:ls_extab TYPE slis_extab.

  CLEAR:ls_extab.

  REFRESH:pt_extab.
* Populate unwated FCT cfodes to be hidden
  ls_extab-fcode =  '&INFO'.
  APPEND ls_extab TO pt_extab.

  SET PF-STATUS 'ZMEN_ALV1' EXCLUDING pt_extab.

ENDFORM.                    "f_pf_status_set
*&---------------------------------------------------------------------*
*&      Form  SMARTFORMS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM smartforms .
*  BREAK-POINT.
*READ TABLE gt_final INTO gs_final INDEX selfield-tabindex.
** call the smartforms thro alv outpout
*  DATA
*      fm_name1 TYPE  rs38l_fnam.
*  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
*    EXPORTING
*      formname           = 'ZPURACHES_ORDER'
**     VARIANT            = ' '
**     DIRECT_CALL        = ' '
*    IMPORTING
*      fm_name            = fm_name1
*    EXCEPTIONS
*      no_form            = 1
*      no_function_module = 2
*      OTHERS             = 3.
*  IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.
*  ls_ctrlop-no_dialog = 'X'.
*  ls_ctrlop-preview = 'X'.
*  ls_compop-tddest = 'LP01'.
**  BREAK-POINT.
*CALL FUNCTION FM_NAME1
*  EXPORTING
*   CONTROL_PARAMETERS         =   ls_ctrlop
*   OUTPUT_OPTIONS             = ls_compop
*   USER_SETTINGS              = 'X'
*   gt_ekko_ekpo               = GT_FINAL
** 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.                    "smartforms


*Print the header data and logo in alv reports programs

FORM f_top_of_page.                                         "#EC CALLED

*  WRITE:/'Delivery Report'.  " List display but not grids
* display log and header in alv reports
  REFRESH gt_header.
* Populate header data
  gs_header-typ = 'H'. "H/S/A->" H = Header, S = Selection, A = Action
  gs_header-key = 'Puraches order'.
  gs_header-info = 'Puraches order'.
  APPEND gs_header TO gt_header.

  gs_header-typ = 'A'. "H/S/A->" H = Header, S = Selection, A = Action
  WRITE:sy-datum TO gs_header-key,
        sy-datum TO gs_header-info.

  CONCATENATE:'Date->' gs_header-key INTO gs_header-key,
              'Date->' gs_header-info INTO gs_header-info.
  APPEND gs_header TO gt_header.

* Display Header
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = gt_header
      i_logo                   = 'LOGO1' "<--OAER
* Note: Logos cannot be displayed other than Grids

*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

ENDFORM.                    "f_top_of_page
*&---------------------------------------------------------------------*
*&      Form  LAYOUT_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM layout_alv .
  gs_layout-confirmation_prompt = gc_x.
* 2. Pass an additional field to Layout Work Area
  gs_layout-box_fieldname = 'BOX'.
* 3. Pass an Additional field to Layout Work area
*  gs_layout-info_fieldname = 'ROW_COL'.  " Row Level Color
* 3. Pass an Additional field to Layout Work area
*  gs_layout-coltab_fieldname = 'IT_CELL_COL'. " Cell in colour
*  gs_layout-edit = 'X'.

ENDFORM.                    " LAYOUT_ALV
*&---------------------------------------------------------------------*
*&      Form  F_FILE_SHELP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_file_shelp .
* local data declarations
  DATA:lv_file TYPE ibipparms-path.

  CLEAR lv_file.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
*     DYNPRO_NUMBER = SYST-DYNNR
      field_name    = p_file
    IMPORTING
      file_name     = lv_file.
* Move selected file path to P_FILE
  p_file = lv_file.

ENDFORM.                    " F_FILE_SHELP
*&---------------------------------------------------------------------*
*&      Form  F_DOWNLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_download .
* Local data declarations
  DATA:lv_file TYPE string.

  CLEAR:lv_file.
* Convert type
  lv_file = p_file.

*  LOOP AT gt_final INTO gs_final.
*    WRITE:....
*  ENDLOOP.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*     BIN_FILESIZE            =
      filename                = lv_file"p_file
*     FILETYPE                = 'ASC'
*     APPEND                  = ' '
      write_field_separator   = '|' " |-> Tab delimeter
    TABLES
      data_tab                = gt_final
*     FIELDNAMES              =
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    MESSAGE 'data downlode compted' TYPE 'I'.
  ENDIF.

ENDFORM.                    " F_DOWNLOAD
*&---------------------------------------------------------------------*
*&      Form  F_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_upload .
* Local data declarations
  DATA:lv_file TYPE string.

  CLEAR:lv_file.
* Convert type
  lv_file = p_file.

*  LOOP AT gt_final INTO gs_final.
*    WRITE:....
*  ENDLOOP.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = lv_file
*     FILETYPE                = 'ASC'
      has_field_separator     = '|'
    TABLES
      data_tab                = gt_final
    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.
  ELSE.
    MESSAGE 'data uplode in server' TYPE 'I'.
  ENDIF.

ENDFORM.                    " F_UPLOAD
*&---------------------------------------------------------------------*
*&      Form  F_DISPLAY_EKKPO_EKPO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_display_ekkpo_ekpo .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'F_PF_STATUS_SET' " MENU STATUS IN ALV REPORTS
      i_callback_user_command  = 'DISPLAY_ITEM'
      i_callback_top_of_page   = 'F_TOP_OF_PAGE' " GETTING HEADDER AND LOGO IN ALV REPORTS
      is_layout                = gs_layout
      it_fieldcat              = gt_fact
      it_sort                  = gt_sort
      it_events                = gt_events
    TABLES
      t_outtab                 = gt_final
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

ENDFORM.                    " F_DISPLAY_EKKPO_EKPO
*&---------------------------------------------------------------------*
*&      Form  F_DISPLAY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LT_FINAL  text
*----------------------------------------------------------------------*
form F_DISPLAY_DATA  tables   PT_final.
 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          = 'F_PF_STATUS_SET'
       i_callback_user_command           = 'F_USER_COMMAND'
*       i_callback_top_of_page            = 'F_TOP_OF_PAGE'
* Note:1.Program name to be passed to trigger an Event TOP_OF_PAGE
*      2.Call back parameter for TOP_OF_PAGE isn't available for List displays

*       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*       I_CALLBACK_HTML_END_OF_LIST       = ' '
*       i_structure_name                  = gc_str"'ZB50_DEL_STR' " DDIC Strcture
*       I_BACKGROUND_ID                   = ' '
*       I_GRID_TITLE                      =
*       I_GRID_SETTINGS                   =
       is_layout                         = gs_layout
       it_fieldcat                       = gt_fact " Populated Field Catalogue
*       IT_EXCLUDING                      =
*       IT_SPECIAL_GROUPS                 =
*       IT_SORT                           =
*       IT_FILTER                         =
*       IS_SEL_HIDE                       =
*       I_DEFAULT                         = 'X'
*       I_SAVE                            = ' '
*       IS_VARIANT                        =
       it_events                         = gt_events " Populated 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                          = pt_final "gt_final
     EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
              .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

endform.                    " F_DISPLAY_DATA


*sel include

notepad:

text symbols:

001 ALV REPORTS
002 FIFLE SERVER
E05 value not exit
F02 EBELP
F03 MATNR
F04 MENGE
F05 NETPR
P02 1
P03 2
P04 3
S02 ITEM
S03 MATERIAL
S04 QUANTITY
T02 GT_FINAL


selection text

ALV ALV GRID
DOWNLODE DOWNLODE
P_DWND DOWNLOAD TO PC
P_FILE Field name
P_UPLD uploade TO SERVER
S_EBELN Purchasing Document
S_EKORG .

Comments

  1. This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it! sap course hyderabad

    ReplyDelete

Post a Comment

Popular posts from this blog

all user exit mv45afzz (implicit user exit )

How to Give Dropdown in alv report in sap abap programming Language

Long Text in input and output field in module pool