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

open datset

Hi,

is there any changes for the following code to be done.

very urgent please.

form writefile.

data: msg(100).

data: todir like rsmrgstr-path value '/apps/B2B/B2Bprog/'.

data: tofile like edi_path-pthnam.

clear msg.

concatenate todir 'abc' sy-datum sy-uzeit w_seqno '.xml'

into tofile.

open dataset tofile for output in text mode encoding default

message msg.

if sy-subrc ne 0.

message e122(j4) with tofile.

else.

loop at wlines.

transfer wlines to tofile.

endloop.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:56 AM

    Hello,

    Declare the tofile like RLGRAP-FILENAME.

    Use Close Dataset at the end after transfering the data.

    if useful reward.

    vasanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:56 AM

    hi Srini,

    data: tofile like <b>RLGRAP-FILENAME</b>.

    in concatenate statement each has to be separated with '/' i.e,

    [code] concatenate todir 'abc' '/' sy-datum '/' sy-uzeit'/' w_seqno '.xml'

    into tofile.[/code]

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:57 AM

    It looks fine ...just make sure to close the file after the loop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:58 AM

    use

    close dataset tofile.

    and also

    declare todir and tofile as rlgrap-filename.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 10:17 AM

    Hi Srini,

    Declare todir and tofile like dxfields-longpath(for application server)

    data: todir like dxfields-longpath value '/apps/B2B/B2Bprog/'.

    data: tofile like dxfields-longpath.

    At last add CLOSE dataset.

    Regards,

    Balaji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 04:23 PM

    HI,

    CHECK THE SAMPLE PROGRAM.

    REPORT zalvbdcprogram

    LINE-COUNT 65

    LINE-SIZE 120

    NO STANDARD PAGE HEADING

    MESSAGE-ID zz.

    &----


    *tables declaration

    &----


    TABLES: mara, mard, marc, t001.

    &----


    *type pools declaration

    &----


    TYPE-POOLS: slis , icon.

    &----


    *data declaration

    &----


    DATA: dg_repid LIKE sy-repid.

    DATA: dt_fldcat TYPE slis_t_fieldcat_alv.

    DATA: FILE TYPE STRING.

    &----


    *internal table declaration

    &----


    DATA: BEGIN OF it_final OCCURS 0,

    matnr LIKE mara-matnr, "Material Number

    maktx LIKE makt-maktx, "Material Description

    ausme LIKE marc-ausme, "Unit of issue

    labst LIKE mard-labst, "Valuated stock

    END OF it_final.

    &----


    *selection screen

    &----


    *for select options

    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-002.

    SELECT-OPTIONS: s_matnr FOR mara-matnr.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-003.

    SELECT-OPTIONS: s_werks FOR mard-werks.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-004.

    SELECT-OPTIONS: s_lgort FOR mard-lgort.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: END OF BLOCK b1.

    *for radiobuttons

    SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-005.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-006.

    PARAMETER: r1 RADIOBUTTON GROUP g2.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-007.

    PARAMETER: r2 RADIOBUTTON GROUP g2.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: END OF BLOCK b2.

    SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-008.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-009.

    PARAMETER: r3 RADIOBUTTON GROUP g1.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-010.

    PARAMETER: r4 RADIOBUTTON GROUP g1.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: END OF BLOCK b3.

    *for file path

    SELECTION-SCREEN: BEGIN OF BLOCK b4 WITH FRAME TITLE text-011.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-012.

    PARAMETER: p_file TYPE rlgrap-filename.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: BEGIN OF LINE.

    SELECTION-SCREEN: COMMENT 1(20) text-013.

    PARAMETER: p_file1 TYPE rlgrap-filename default 'ameena.txt'.

    SELECTION-SCREEN: END OF LINE.

    SELECTION-SCREEN: END OF BLOCK b4.

    &----


    *at selection screen

    &----


    AT SELECTION-SCREEN.

    *validating material

    IF s_matnr-low IS NOT INITIAL.

    SELECT SINGLE matnr FROM mara

    INTO mara-matnr WHERE matnr = s_matnr-low.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid material number'.

    ENDIF.

    ENDIF.

    IF s_matnr-high IS NOT INITIAL.

    SELECT SINGLE matnr FROM mara

    INTO mara-matnr WHERE matnr = s_matnr-high.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid material number'.

    ENDIF.

    ENDIF.

    *validating plant

    IF s_werks-low IS NOT INITIAL.

    SELECT SINGLE werks FROM mard

    INTO mard-werks WHERE werks = s_werks-low.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid material number'.

    ENDIF.

    ENDIF.

    IF s_werks-high IS NOT INITIAL.

    SELECT SINGLE werks FROM mard

    INTO mard-werks WHERE werks = s_werks-high.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid plant'.

    ENDIF.

    ENDIF.

    *validating storage location

    IF s_lgort-low IS NOT INITIAL.

    SELECT SINGLE lgort FROM mard

    INTO mard-lgort WHERE lgort = s_lgort-low.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid material number'.

    ENDIF.

    ENDIF.

    IF s_werks-high IS NOT INITIAL.

    SELECT SINGLE werks FROM mard

    INTO mard-werks WHERE werks = s_werks-high.

    IF sy-subrc <> 0.

    MESSAGE e999(zz) WITH 'invalid plant'.

    ENDIF.

    ENDIF.

    &----


    *at selection screen on value request for p_file

    &----


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    PERFORM file_help USING p_file.

    FILE = P_FILE.

    &----


    *& Form file_help

    &----


    FORM file_help USING p_p_file.

    DATA: s_file TYPE ibipparms-path.

    CALL FUNCTION 'F4_FILENAME'

    • EXPORTING

    • PROGRAM_NAME = SYST-CPROG

    • DYNPRO_NUMBER = SYST-DYNNR

    • FIELD_NAME = ' '

    IMPORTING

    file_name = s_file

    .

    p_p_file = s_file.

    ENDFORM. " file_help

    &----


    *start-of-selection

    &----


    START-OF-SELECTION.

    SELECT mara~matnr

    makt~maktx

    marc~ausme

    mard~labst

    INTO TABLE it_final

    FROM mara INNER JOIN makt ON maramatnr = maktmatnr

    INNER JOIN marc ON maramatnr = marcmatnr

    INNER JOIN mard ON maramatnr = mardmatnr

    WHERE mara~matnr IN s_matnr AND

    mard~werks IN s_werks AND

    mard~lgort IN s_lgort.

    IF r1 = 'X'.

    PERFORM report_display.

    ELSEIF r2 = 'X'.

    PERFORM ps_download USING file.

    ELSE.

    PERFORM as_download USING p_file1.

    ENDIF.

    &----


    *& Form report_display

    &----


    FORM report_display .

    dg_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = dg_repid

    I_INTERNAL_TABNAME = 'IT_FINAL'

    • I_STRUCTURE_NAME =

    • I_CLIENT_NEVER_DISPLAY = 'X'

    I_INCLNAME = dg_repid

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    CHANGING

    CT_FIELDCAT = dt_fldcat

    • EXCEPTIONS

    • INCONSISTENT_INTERFACE = 1

    • PROGRAM_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 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = dg_repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_STRUCTURE_NAME =

    • IS_LAYOUT =

    it_fieldcat = dt_fldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_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

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = it_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. " report_display

    &----


    *& Form as_download

    &----


    FORM as_download USING p_p_file1.

    OPEN DATASET p_p_file1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc <> 0 .

    MESSAGE i000(zz) WITH 'unable to open a file'.

    ENDIF.

    LOOP AT it_final.

    TRANSFER it_final TO p_p_file1 .

    ENDLOOP.

    CLOSE DATASET p_p_file1 .

    ENDFORM. " as_download

    &----


    *& Form ps_download

    &----


    form ps_download using p_file.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    filename = P_FILE

    FILETYPE = 'DAT'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • 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 = ' '

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = IT_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.

    ENDIF.

    endform. " ps_download

    PLEASE PROVIDE POINTS IF USEFUL

    REGARDS,

    DEEPTHI REDDY

    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.