Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

save internal table as dbf format in application server in background

Former Member
0 Likes
1,222

hi,

may i know how to save internal table into dbf format, i need it to be run in background and save into application server.

i cant use GUI_DOWNLOAD as it is only possible for foreground processing.

i have searched through this forum but cant find any clear solution.

please help..

hi,

may i know how to save internal table into dbf format, i need it to be run in background and save into application server.

i cant use GUI_DOWNLOAD as it is only possible for foreground processing.

i have searched through this forum but cant find any clear solution.

please help..

6 REPLIES 6
Read only

Former Member
0 Likes
925

Hi,

I do not think from direct way it is possible to save the internal table into 'DBF' format.

On application server with the 'Open Dataset' 'Write Dataset', you can put the file but it will not be a DBF file.

OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.

Hope this will solve your problem

Rani.

Read only

Former Member
0 Likes
925

hi,

thanks for quick reply, i tried open dataset and transfer but i cant be dbf format.

i know there is a work around that we can download txt format and ask the user to convert it into dbf format manually, but we try not to do that, we want to reduce the manual job.

so do you know any other indirect way i can save as dbf format?

Read only

Former Member
0 Likes
925

Hi,

Please refer to following sample code to Download file on the application server.

REPORT  ZDOWNLOAD_APPL_DEMO.

TYPES : BEGIN OF ST_DEMO,
        REG_NO(10) TYPE C,
        NAME(20) TYPE C,
        ADDR(20) TYPE C,
        END OF ST_DEMO.

DATA : WA_DEMO TYPE ST_DEMO,
       IT_DEMO TYPE TABLE OF ST_DEMO,
       L_FNAME TYPE STRING .

PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\SRI\SYS\src\DOWN.TXT' OBLIGATORY.
L_FNAME = P_FNAME.
WA_DEMO-REG_NO = '100001'.
WA_DEMO-NAME = 'ANAND'.
WA_DEMO-ADDR = 'NAGARKOVIL'.
 APPEND WA_DEMO TO IT_DEMO.

WA_DEMO-REG_NO = '100002'.
WA_DEMO-NAME = 'VIKRAM'.
WA_DEMO-ADDR = 'CHENNAI'.
APPEND WA_DEMO TO IT_DEMO.

  OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
  LOOP AT IT_DEMO INTO WA_DEMO.
    IF SY-SUBRC = 0.
      TRANSFER WA_DEMO TO L_FNAME.
      WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
    ENDIF.
  ENDLOOP.

Hope this helps.

Regards,

Chandravadan

Read only

Former Member
0 Likes
925

hi,

thansk for giving advice, but this download as txt format not dbf format, i need it to be dbf format. understand there might not have direct way to save as dbf format in background but is there any indirect way can advise me?

Read only

0 Likes
925

I using function module "GUI_DOWNLOAD" for export data from SAP Table to file DBF on PC.

You can consult this solution for your request.


*&---------------------------------------------------------------------*
*& Report  ZPG_EXPORT_BDF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZPG_EXPORT_BDF.

TABLES : ZTB_CONTACT.

DATA: BEGIN OF GTY_CONTACT OCCURS 0,
          MANDT TYPE MANDT,
          ID    TYPE ZDD_ID_CON,
          NAME  TYPE ZDD_NAME_CON,
          COMPANY TYPE ZDD_COMPANY,
          MAIL  TYPE ZDD_MAIL_CON,
          PHONE TYPE ZDD_PHONE_CON,
          ADDRESS TYPE ZDD_NAME_CON,
      END OF GTY_CONTACT.

DATA :
 BEGIN OF GTY_PAYMENT OCCURS 0,
  MANDT       TYPE MANDT,
  NGAY_CTU    TYPE ZDD_DATE,
  MA_KHO      TYPE ZDD_MAKHO,
  SO_CTU      TYPE ZDD_SO_CTU,
  TRIGIATT    TYPE ZDD_TGIA_TT,
  MA_TCHI     TYPE ZDD_MA_TCHI,
  DIEN_GIAI   TYPE ZDD_DGIAI,
  MA_KHCNO    TYPE ZDD_MA_KHCNO,
  SO_THE      TYPE ZDD_SO_THE,
 END OF GTY_PAYMENT.

PARAMETERS : pa_file TYPE string "rlgrap-filename
                     DEFAULT 'C:\Users\CanhNQ\Desktop\'.

PERFORM select_data.

PERFORM save
              TABLES GTY_PAYMENT
              USING pa_file.

FORM save TABLES t USING filename.
  DATA: BEGIN OF FIELDNAMES OCCURS 1,
    NAME(60),
  END OF FIELDNAMES.
 TYPE-POOLS: SYDES.
  DATA:
    TD       TYPE SYDES_DESC,
    TD_WA    TYPE SYDES_TYPEINFO,
    TD_NA    TYPE SYDES_NAMEINFO.

  DATA :
 BEGIN OF GWA_PAYMENT OCCURS 0,
  MANDT       TYPE MANDT,
  NGAY_CTU    TYPE ZDD_DATE,
  MA_KHO      TYPE ZDD_MAKHO,
  SO_CTU      TYPE ZDD_SO_CTU,
  TRIGIATT    TYPE ZDD_TGIA_TT,
  MA_TCHI     TYPE ZDD_MA_TCHI,
  DIEN_GIAI   TYPE ZDD_DGIAI,
  MA_KHCNO    TYPE ZDD_MA_KHCNO,
  SO_THE      TYPE ZDD_SO_THE,
 END OF GWA_PAYMENT.

  DESCRIBE FIELD: t INTO TD.

  LOOP AT TD-TYPES into TD_WA.
    CHECK TD_WA-IDX_NAME ne 0.
    READ TABLE TD-NAMES INTO TD_NA INDEX TD_WA-IDX_NAME.
    CHECK sy-subrc EQ 0.
    FIELDNAMES-NAME = TD_NA.
    APPEND FIELDNAMES.
  ENDLOOP.

    DATA: WA_PAYMENT TYPE ZTB_PAYMENT.
      CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILETYPE = 'DBF'
        filename = filename
*        CODEPAGE = filecodepage
        APPEND   = 'A'
      TABLES
        data_tab = t
      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.
*    ENDLOOP.

    IF sy-subrc = 0.
      WRITE: 'Done !'.
    ELSE.
      WRITE: 'Error !'.
    ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SELECT_DATA .
   SELECT * FROM ZTB_PAYMENT INTO TABLE GTY_PAYMENT.

ENDFORM.                    " SELECT_DATA

Read only

Former Member
0 Likes
925

Lau Mingo

Good morning, did you solve the problem you had?

Could you help me, I urgently need a way to solve this problem