Skip to Content
author's profile photo Former Member
Former Member

data retrieval

Dear Experts,

I have a requirement that i have to retrieve data from all the PA tables for one or multiple pernr's and download it to a text file.please help me out which function module will be suitable.please suggest me some logic. thanks in advance

Raj

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 06:17 AM

    Raj,

    Use this Example.

    RH_START_EXCEL_WITH_DATA

    TABLES: VBAK,VBAP.

    DATA: BEGIN OF I_VBAK OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    ERDAT LIKE VBAK-ERDAT,

    ERNAM LIKE VBAK-ERNAM,

    AUDAT LIKE VBAK-AUDAT,

    VBTYP LIKE VBAK-VBTYP,

    END OF I_VBAK.

    DATA: BEGIN OF I_VBAP OCCURS 0,

    VBELN LIKE VBAP-VBELN,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    CHARG LIKE VBAP-CHARG,

    MATKL LIKE VBAP-MATKL,

    END OF I_VBAP.

    DATA: BEGIN OF IT_VBAK OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    ERDAT LIKE VBAK-ERDAT,

    ERNAM LIKE VBAK-ERNAM,

    AUDAT LIKE VBAK-AUDAT,

    VBTYP LIKE VBAK-VBTYP,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    CHARG LIKE VBAP-CHARG,

    MATKL LIKE VBAP-MATKL,

    END OF IT_VBAK.

    SELECT VBELN ERDAT ERNAM AUDAT VBTYP FROM VBAK INTO TABLE I_VBAK.

    SELECT VBELN POSNR MATNR CHARG MATKL FROM VBAP INTO TABLE I_VBAP.

    SORT: I_VBAK BY VBELN,I_VBAP BY VBELN.

    LOOP AT I_VBAK.

    READ TABLE I_VBAP WITH KEY VBELN = I_VBAK-VBELN BINARY SEARCH.

    IF SY-SUBRC = 0.

    MOVE I_VBAK-VBELN TO IT_VBAK-VBELN.

    MOVE I_VBAK-ERDAT TO IT_VBAK-ERDAT.

    MOVE I_VBAK-ERNAM TO IT_VBAK-ERNAM.

    MOVE I_VBAK-AUDAT TO IT_VBAK-AUDAT.

    MOVE I_VBAK-VBTYP TO IT_VBAK-VBTYP.

    MOVE I_VBAP-POSNR TO IT_VBAK-POSNR.

    MOVE I_VBAP-MATNR TO IT_VBAK-MATNR.

    MOVE I_VBAP-CHARG TO IT_VBAK-CHARG.

    MOVE I_VBAP-MATKL TO IT_VBAK-MATKL.

    APPEND IT_VBAK.

    ENDIF.

    ENDLOOP.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE =

    FILENAME = 'D:\C5.DOC'

    FILETYPE = 'ASC' "Separate Columns by Tabs in Case of ASCII Download

    APPEND = ' '

    WRITE_FIELD_SEPARATOR = 'X'

    HEADER = '00'

    TRUNC_TRAILING_BLANKS = ' '

    WRITE_LF = 'X'

    COL_SELECT = ' '

    COL_SELECT_MASK = ' '

    DAT_MODE = ' '

    CONFIRM_OVERWRITE = 'X' "Overwrite The File Only After

    Confirmation

    NO_AUTH_CHECK = ' '

    CODEPAGE = ' '

    IGNORE_CERR = ABAP_TRUE

    REPLACEMENT = '#'

    WRITE_BOM = ' '

    TRUNC_TRAILING_BLANKS_EOL = 'X'

    WK1_N_FORMAT = ' '

    WK1_N_SIZE = ' '

    WK1_T_FORMAT = ' '

    WK1_T_SIZE = ' '

    WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

    IMPORTING

    FILELENGTH =

    TABLES

    DATA_TAB = IT_VBAK

    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.

    ENDIF.

    DhanaLakshmi M S

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      thank u very much for ur advice Dhana lakshmi .

      but as i said i have to fetch data from all the PA tables which are filled for that pernr.so for every infotypes if i create the internal table then the program will be very huge can we do it using logical database?

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 06:18 AM

    Hi,

    Try using FM: RFC_READ_TABLE, pass the table name dynamically and you can read the output in an internal table and disp;lay that or use GUI_DOWNLOAD to download to a txt file.

    Check help for documentation.

    Regards,

    Subramanian

    Edited by: Subramanian PL on Jun 18, 2008 11:20 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.