Application Development 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: 

How to use the functional module DDIF_FIELDINFO_GET

Former Member
0 Kudos

I wanted to download the table into an xls with the fieldnames .how do i do that?

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi Nilotpala,

Welcome to SDN.

You can code something like this. Let's say you want to download table MARA fieldnames.

DATA: BEGIN OF I_DFIES OCCURS 0.
        INCLUDE STRUCTURE DFIES.
DATA: END OF I_DFIES.


CALL FUNCTION 'DDIF_FIELDINFO_GET'
  EXPORTING
    TABNAME              = 'MARA'
    LANGU                = SY-LANGU
  TABLES
    DFIES_TAB            = I_DFIES
  EXCEPTIONS
    NOT_FOUND            = 1
    INTERNAL_ERROR       = 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.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = 'C:/TEMP/MARA.XLS'
    FILETYPE                        = 'DAT'
  TABLES
    DATA_TAB                        = I_DFIES
  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.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

2 REPLIES 2

ferry_lianto
Active Contributor
0 Kudos

Hi Nilotpala,

Welcome to SDN.

You can code something like this. Let's say you want to download table MARA fieldnames.

DATA: BEGIN OF I_DFIES OCCURS 0.
        INCLUDE STRUCTURE DFIES.
DATA: END OF I_DFIES.


CALL FUNCTION 'DDIF_FIELDINFO_GET'
  EXPORTING
    TABNAME              = 'MARA'
    LANGU                = SY-LANGU
  TABLES
    DFIES_TAB            = I_DFIES
  EXCEPTIONS
    NOT_FOUND            = 1
    INTERNAL_ERROR       = 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.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = 'C:/TEMP/MARA.XLS'
    FILETYPE                        = 'DAT'
  TABLES
    DATA_TAB                        = I_DFIES
  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.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

Former Member
0 Kudos

Hi,

Thanks a lot for the reply Ferry.

But on downloading the table fields all other attributes like the data elements are also being populated how do i get the fieldnames populated in the first row of the document.

Regards,

Nilotpala