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

Open data set + header+ item records

HI all,

I want to download the data. I am using the Open data set for to put the data in file.

But My internal table contains the header record and Item records.

How can i use open data set for Header and item records. (REf: MB51).

if you give any sample program Apppriciated.

regards,

Ajay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 01:00 PM

    &----


    *& Report ZSAMP_PP_REQ *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZSAMP_PP_REQ NO STANDARD PAGE HEADING

    LINE-SIZE 240

    LINE-COUNT 65.

    *----


    • TABLES DECLARATION

    *----


    TABLES: marc.

    *----


    • TYPES DECLARATION

    *----


    TYPES: BEGIN OF t_pbim,

    pbdnr TYPE pbim-pbdnr, "Requirements plan number

    matnr TYPE pbim-matnr, "material number

    bedae TYPE pbim-bedae, "Requirements type

    versb TYPE pbim-versb,

    vervs TYPE pbim-vervs,

    bdzei TYPE pbim-bdzei,

    werks TYPE pbim-werks,

    mcinc TYPE pbim-mcinc,

    stfna TYPE pbim-stfna,

    vrsic TYPE pbim-vrsic,

    knttp TYPE pbim-knttp,

    sobkz TYPE pbim-sobkz,

    kzvbr TYPE pbim-kzvbr,

    pspel TYPE pbim-pspel,

    kdpos TYPE pbim-kdpos,

    kdauf TYPE pbim-kdauf,

    uebkz TYPE pbim-uebkz,

    datlp TYPE pbim-datlp,

    uhrlp TYPE pbim-uhrlp,

    kzbws TYPE pbim-kzbws,

    oplkz TYPE pbim-oplkz,

    berid TYPE pbid-berid,

    END OF t_pbim.

    TYPES : BEGIN OF t_pbid,

    pbdnr TYPE pbim-pbdnr,

    berid TYPE pbid-berid,

    END OF t_pbid.

    TYPES : BEGIN OF t_pbed,

    bdzei TYPE pbed-bdzei,

    entlu TYPE pbed-entlu,

    plnmg TYPE pbed-plnmg,

    sernr TYPE pbed-sernr,

    verid TYPE pbed-verid,

    END OF t_pbed.

    TYPES : BEGIN OF t_pbed1,

    rif(10) TYPE n,

    entlu TYPE pbed-entlu,

    edatu(8),

    plnmg(13),

    sernr TYPE pbed-sernr,

    verid TYPE pbed-verid,

    END OF t_pbed1.

    TYPES : BEGIN OF t_final,

    rif(10) TYPE n,

    matnr TYPE pbim-matnr,

    bedae TYPE pbim-bedae,

    versb TYPE pbim-versb,

    vervs TYPE pbim-vervs,

    pbdnr TYPE pbim-pbdnr,

    werks TYPE pbim-werks,

    mcinc TYPE pbim-mcinc,

    stfna TYPE pbim-stfna,

    vrsic TYPE pbim-vrsic,

    knttp TYPE pbim-knttp,

    sobkz TYPE pbim-sobkz,

    kzvbr TYPE pbim-kzvbr,

    pspel TYPE pbim-pspel,

    kdpos TYPE pbim-kdpos,

    kdauf TYPE pbim-kdauf,

    aprog LIKE pbim-uebkz,

    datlp(8) TYPE c,

    uhrlp TYPE pbim-uhrlp,

    kzbws TYPE pbim-kzbws,

    berid TYPE pbid-berid,

    oplkz TYPE pbim-oplkz,

    END OF t_final.

    TYPES : BEGIN OF t_text,

    tline(1300) TYPE c,

    END OF t_text.

    TYPES: BEGIN OF t_header,

    text(100) TYPE c,

    END OF t_header.

    *----


    • INTERNAL TABLE DECLARATION

    *----


    DATA : i_pbim TYPE STANDARD TABLE OF t_pbim,

    i_pbid TYPE STANDARD TABLE OF t_pbid,

    i_pbed TYPE STANDARD TABLE OF t_pbed,

    i_pbed1 TYPE STANDARD TABLE OF t_pbed1,

    i_final TYPE STANDARD TABLE OF t_final,

    i_header TYPE STANDARD TABLE OF t_header.

    *----


    • WORKAREA DECLARATION

    *----


    DATA: wa_pbim TYPE t_pbim,

    wa_pbid TYPE t_pbid,

    wa_final TYPE t_final,

    wa_text TYPE t_text,

    wa_pbed TYPE t_pbed,

    wa_pbed1 TYPE t_pbed1,

    wa_header TYPE t_header,

    v_count(10) TYPE n,

    v_plnmg(13),

    v_dcpfm TYPE usr01-dcpfm.

    ----


    • CONSTANTS DECLARATIONS

    ----


    CONSTANTS: con_tab TYPE x VALUE '09',

    c_actvt(2) VALUE '03',

    c_mask(9) VALUE ',.,..',

    c_save(1) VALUE 'O',

    c_x(1) VALUE 'X',

    c_sep(1) VALUE '/',

    c_cama(1) VALUE ',',

    c_space(1) VALUE '',

    c_dec(1) VALUE'.'.

    *----


    • SELECTION SCREEN

    *----


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

    SELECT-OPTIONS: s_matnr FOR marc-matnr, " Material Number

    s_werks FOR marc-werks OBLIGATORY. " Plant

    SELECTION-SCREEN END OF BLOCK b1.

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

    PARAMETERS :Rb_wsd RADIOBUTTON GROUP zsum,

    p_wsfn1 LIKE rlgrap-filename

    default 'c:\sai\header_data1.txt',

    • DEFAULT 'C:\TEMP\header_data1.txt',

    p_wsfn2 LIKE rlgrap-filename

    default 'c:\sai\details_data1.txt',

    • DEFAULT 'C:\TEMP\details_data1.txt',

    Rb_app RADIOBUTTON GROUP zsum,

    p_dsserv LIKE filename-fileextern

    DEFAULT '/celestica/interface/ca/out/work',

    p_dfile1 LIKE rlgrap-filename DEFAULT 'header_data.txt',

    p_dfile2 LIKE rlgrap-filename DEFAULT 'details_data.txt'.

    selection-screen skip 2.

    parameters:rb_disp radiobutton group zsum.

    SELECTION-SCREEN END OF BLOCK b2.

    ----


    • AT SELECTION-SCREEN

    ----


    AT SELECTION-SCREEN.

    IF rb_wsd = 'X' AND ( p_wsfn1 IS INITIAL OR

    p_wsfn2 IS INITIAL ).

    MESSAGE e001(00) wiTH 'Enter the Workstation Download file'(t27).

    • MESSAGE e001(00)(00) WITH 'Enter the Workstation Download file'.

    ELSEIF rb_app = 'X' AND ( p_dsserv IS INITIAL OR

    p_dfile1 IS INITIAL OR

    p_dfile2 IS INITIAL ).

    MESSAGE e001(00) WITH 'Enter the Logical Path & FileName'(t28).

    ENDIF.

    **----


    • At Selection Screen *

    *----


    AT SELECTION-SCREEN ON s_matnr.

    IF NOT s_matnr IS INITIAL.

    PERFORM valid_materialno.

    ENDIF.

    AT SELECTION-SCREEN ON s_werks.

    PERFORM valid_plant.

    ----


    • AT SELECTION-SCREEN ON VALUE REQUEST

    ----


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_wsfn1.

    PERFORM file_f4_help USING p_wsfn1.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_wsfn2.

    PERFORM file_f4_help USING p_wsfn2.

    *----


    • START-OF-SELECTION

    *----


    START-OF-SELECTION.

    PERFORM get_data_pbim. " Data retrival from pbim table

    PERFORM get_data_pbid.

    PERFORM get_data_pbed. " get data from pbed table

    PERFORM prepare_data.

    *----


    • END-OF-SELECTION

    *----


    IF rb_wsd = c_x.

    PERFORM download1.

    ELSEIF rb_app = C_X.

    PERFORM open_dataset.

    ENDIF.

    if rb_disp = c_x.

    perform DISP_DATA.

    endif.

    &----


    *& Form valid_materialno

    &----


    FORM valid_materialno.

    SELECT COUNT(*)

    FROM mara

    WHERE matnr IN s_matnr.

    IF sy-subrc <> 0.

    MESSAGE e001(00) WITH 'No material found in given range'(t29).

    ENDIF.

    ENDFORM. " valid_materialno

    &----


    *& Form valid_plant

    &----


    FORM valid_plant.

    SELECT COUNT(*)

    FROM t001w

    WHERE werks IN s_werks.

    IF sy-subrc NE 0 .

    MESSAGE e001(00) WITH 'No Plant found in given range'(t30).

    • ELSE.

    **If Plant exists then check Authorization for Plant

    • CALL FUNCTION 'ZU_DATA_ACCESS_AUTH_CHECK'

    • EXPORTING

    • actvt = c_actvt

    • TABLES

    • s_werks = s_werks

    • EXCEPTIONS

    • bukrs_failed = 1

    • vkorg_failed = 2

    • vtweg_failed = 3

    • ekorg_failed = 4

    • werks_failed = 5

    • lgnum_failed = 6

    • OTHERS = 7.

    • IF sy-subrc <> 0.

    • MESSAGE e001(00) WITH 'You are not authorized for plant'(t31).

    • ENDIF.

    ENDIF.

    ENDFORM. " valid_plant

    &----


    *& Form file_f4_help

    &----


    FORM file_f4_help USING l_file TYPE rlgrap-filename.

    CALL FUNCTION 'WS_FILENAME_GET'

    EXPORTING

    def_filename = l_file

    mask = c_mask

    mode = c_save

    title = ' '

    IMPORTING

    filename = l_file

    EXCEPTIONS

    inv_winsys = 1

    no_batch = 2

    selection_cancel = 3

    selection_error = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    MESSAGE e001(00) WITH 'Error in getting the F4 help'(t32).

    ENDIF.

    ENDFORM. " file_f4_help

    &----


    *& Form get_data

    &----


    FORM get_data_pbim.

    CLEAR: wa_pbim.

    • select the data from PBIM table

    SELECT pbdnr

    matnr

    bedae

    versb

    vervs

    bdzei

    werks

    mcinc

    stfna

    vrsic

    knttp

    sobkz

    kzvbr

    pspel

    kdpos

    kdauf

    uebkz

    datlp

    uhrlp

    kzbws

    oplkz

    FROM pbim

    INTO TABLE i_pbim

    WHERE matnr IN s_matnr AND

    werks IN s_werks.

    IF sy-subrc = 0.

    SORT i_pbim BY matnr.

    ENDIF.

    ENDFORM. " get_data

    &----


    *& Form download

    &----


    FORM download TABLES i_tab TYPE STANDARD TABLE

    USING wsfile TYPE rlgrap-filename.

    DATA : v_file1 TYPE string.

    CLEAR: v_file1.

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    filename = wsfile

    filetype = 'DAT'

    TABLES

    data_tab = i_tab

    fieldnames = i_header

    EXCEPTIONS

    file_open_error = 1

    file_write_error = 2

    invalid_filesize = 3

    invalid_type = 4

    no_batch = 5

    unknown_error = 6

    invalid_table_width = 7

    gui_refuse_filetransfer = 8

    customer_error = 9

    OTHERS = 10.

    IF sy-subrc EQ 0.

    CONCATENATE 'File Successfully downloaded into'(t33) wsfile

    INTO v_file1 SEPARATED BY space.

    WRITE :/ v_file1.

    REFRESH i_tab[].

    ENDIF.

    ENDFORM. " download

    &----


    *& Form DOWNLOAD1

    &----


    FORM download1.

    IF NOT i_pbim[] IS INITIAL.

    PERFORM prepare_header.

    PERFORM download TABLES i_final[]

    USING p_wsfn1.

    ELSE.

    WRITE:/ 'No records to download for the specified file path'(t34),

    p_wsfn1.

    ENDIF.

    IF NOT i_pbed1[] IS INITIAL.

    PERFORM prepare_header1.

    PERFORM download TABLES i_pbed1[]

    USING p_wsfn2.

    ELSE.

    WRITE:/ 'No records to download for the specified file path'(t26),

    p_wsfn2.

    ENDIF.

    ENDFORM. " DOWNLOAD1

    &----


    *& Form OPEN_DATASET

    &----


    FORM open_dataset.

    IF NOT i_final[] IS INITIAL. "i_pbim[]

    PERFORM physical_filename USING p_dfile1.

    OPEN DATASET p_dfile1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc = 0.

    CLEAR wa_text.

    CLEAR wa_final.

    PERFORM header1.

    TRANSFER wa_text TO p_dfile1.

    CLEAR wa_text.

    LOOP AT i_final INTO wa_final.

    PERFORM con_fields.

    TRANSFER wa_text TO p_dfile1.

    CLEAR wa_text.

    ENDLOOP.

    CLOSE DATASET p_dfile1.

    IF sy-subrc = 0.

    MESSAGE s001(00) WITH 'File Downloaded to Application Server'(t35).

    ELSE.

    MESSAGE s001(00) WITH 'File could not be closed'(t36).

    ENDIF.

    ELSE.

    WRITE:/ 'Error in file opening'(t37), p_dfile1.

    ENDIF.

    ELSE.

    WRITE:/ 'No records to download for the specified file path'(t38),

    p_dfile1.

    ENDIF.

    IF NOT i_pbed1[] IS INITIAL.

    PERFORM physical_filename USING p_dfile2.

    OPEN DATASET p_dfile2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc = 0.

    CLEAR wa_text.

    CLEAR wa_pbed.

    PERFORM header2.

    TRANSFER wa_text TO p_dfile2.

    CLEAR wa_text.

    LOOP AT i_pbed1 INTO wa_pbed1.

    PERFORM con_fields1.

    TRANSFER wa_text TO p_dfile2.

    CLEAR wa_text.

    ENDLOOP.

    CLOSE DATASET p_dfile2.

    IF sy-subrc = 0.

    MESSAGE s001(00) WITH 'File Downloaded to Application Server'(t35).

    ELSE.

    MESSAGE s001(00) WITH 'File could not be closed'(t36).

    ENDIF.

    ELSE.

    WRITE:/ 'Error in file opening'(t37), p_dfile1.

    ENDIF.

    ELSE.

    WRITE:/ 'No records to download for the specified file path'(t38),

    p_dfile1.

    ENDIF.

    ENDFORM. " OPEN_DATASET

    &----


    *& Form PHYSICAL_FILENAME

    &----


    • text

    ----


    • -->P_P_WSFN1 text

    ----


    FORM physical_filename USING l_dsfile TYPE rlgrap-filename.

    SET LOCALE LANGUAGE sy-langu.

    TRANSLATE l_dsfile TO LOWER CASE.

    CONCATENATE p_dsserv c_sep l_dsfile INTO l_dsfile.

    TRANSLATE l_dsfile TO LOWER CASE.

    ENDFORM. " PHYSICAL_FILENAME

    &----


    *& Form get_data2

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_data_pbed.

    CHECK NOT i_pbim[] IS INITIAL.

    SELECT bdzei

    entlu

    plnmg

    sernr

    verid

    FROM pbed

    INTO TABLE i_pbed

    FOR ALL ENTRIES IN i_pbim

    WHERE bdzei = i_pbim-bdzei.

    IF sy-subrc = 0.

    SORT i_pbed BY entlu.

    ENDIF.

    SELECT SINGLE dcpfm FROM usr01 INTO v_dcpfm

    WHERE bname = sy-uname.

    ENDFORM. " get_data2

    &----


    *& Form prepare_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM prepare_data.

    CLEAR : wa_final.

    v_count = '0000000001'.

    SORT i_pbim BY pbdnr.

    LOOP AT i_pbim INTO wa_pbim.

    READ TABLE i_pbid INTO wa_pbid WITH KEY pbdnr = wa_pbim-pbdnr

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE wa_pbid-berid TO wa_final-berid.

    ENDIF.

    MOVE: wa_pbim-matnr TO wa_final-matnr,

    v_count TO wa_final-rif,

    wa_pbim-bedae TO wa_final-bedae,

    wa_pbim-versb TO wa_final-versb,

    wa_pbim-vervs TO wa_final-vervs,

    wa_pbim-pbdnr TO wa_final-pbdnr,

    wa_pbim-werks TO wa_final-werks,

    wa_pbim-mcinc TO wa_final-mcinc,

    wa_pbim-stfna TO wa_final-stfna,

    wa_pbim-vrsic TO wa_final-vrsic,

    wa_pbim-knttp TO wa_final-knttp,

    wa_pbim-sobkz TO wa_final-sobkz,

    wa_pbim-kzvbr TO wa_final-kzvbr,

    wa_pbim-pspel TO wa_final-pspel,

    wa_pbim-kdpos TO wa_final-kdpos,

    wa_pbim-kdauf TO wa_final-kdauf,

    • wa_pbim-uebkz TO wa_final-aprog,

    wa_pbim-uhrlp TO wa_final-uhrlp,

    wa_pbim-kzbws TO wa_final-kzbws,

    wa_pbim-oplkz TO wa_final-oplkz.

    CONCATENATE wa_pbim-datlp6(2) wa_pbim-datlp4(2)

    wa_pbim-datlp+0(4) INTO wa_final-datlp.

    wa_final-aprog = ''.

    APPEND wa_final TO i_final.

    v_count = v_count + 1.

    LOOP AT i_pbed INTO wa_pbed WHERE bdzei = wa_pbim-bdzei.

    wa_pbed1-rif = wa_final-rif.

    wa_pbed1-entlu = wa_pbed-entlu.

    wa_pbed1-edatu = ' '.

    v_plnmg = wa_pbed-plnmg.

    IF v_dcpfm = 'X'.

    REPLACE c_cama WITH c_space

    INTO v_plnmg.

    REPLACE c_dec WITH c_cama

    INTO v_plnmg.

    CONDENSE v_plnmg NO-GAPS.

    ENDIF.

    wa_pbed1-plnmg = v_plnmg.

    wa_pbed1-sernr = wa_pbed-sernr.

    wa_pbed1-verid = wa_pbed-verid.

    APPEND wa_pbed1 TO i_pbed1.

    CLEAR: wa_pbed1, wa_pbed.

    ENDLOOP.

    CLEAR : wa_final,wa_pbim.

    ENDLOOP.

    ENDFORM. " prepare_data

    &----


    *& Form con_fields

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM con_fields.

    DATA : rif(10),

    pbdnr(10),

    matnr(18),

    bedae(4),

    versb(2),

    vervs(1),

    bdzei(12),

    werks(4),

    mcinc(8),

    stfna(30),

    vrsic(3),

    knttp(1),

    sobkz(1),

    kzvbr(1),

    pspel(8),

    kdpos(6),

    kdauf(10),

    ubekz(1),

    datlp(8),

    uhrlp(6),

    kzbws(1),

    oplkz(1),

    berid(10).

    CONCATENATE wa_final-datlp6(2) wa_final-datlp4(2)

    wa_final-datlp+0(4) INTO datlp.

    rif = wa_final-rif.

    pbdnr = wa_final-pbdnr.

    matnr = wa_final-matnr.

    bedae = wa_final-bedae.

    versb = wa_final-versb.

    vervs = wa_final-vervs.

    werks = wa_final-werks.

    mcinc = wa_final-mcinc.

    stfna = wa_final-stfna.

    vrsic = wa_final-vrsic.

    knttp = wa_final-knttp.

    sobkz = wa_final-sobkz.

    kzvbr = wa_final-kzvbr.

    pspel = wa_final-pspel.

    kdpos = wa_final-kdpos.

    kdauf = wa_final-kdauf.

    ubekz = wa_final-aprog.

    WRITE : wa_final-uhrlp TO uhrlp.

    kzbws = wa_final-kzbws.

    oplkz = wa_final-oplkz.

    berid = wa_final-berid.

    CONDENSE: rif,

    matnr,

    bedae,

    versb,

    vervs,

    pbdnr,

    werks,

    mcinc,

    stfna,

    vrsic,

    knttp,

    sobkz,

    kzvbr,

    pspel,

    kdpos,

    kdauf,

    ubekz,

    datlp,

    uhrlp,

    kzbws,

    berid,

    oplkz.

    CONCATENATE rif

    matnr

    bedae

    versb

    vervs

    pbdnr

    werks

    mcinc

    stfna

    vrsic

    knttp

    sobkz

    kzvbr

    pspel

    kdpos

    kdauf

    ubekz

    datlp

    uhrlp

    kzbws

    berid

    oplkz

    INTO wa_text-tline SEPARATED BY space.

    CLEAR: pbdnr,

    matnr,

    bedae,

    versb,

    vervs,

    bdzei,

    werks,

    mcinc,

    stfna,

    vrsic,

    knttp,

    sobkz,

    kzvbr,

    pspel,

    kdpos,

    kdauf,

    datlp,

    uhrlp,

    kzbws,

    oplkz,

    berid,

    rif,

    ubekz.

    ENDFORM. " con_fields

    &----


    *& Form con_fields1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM con_fields1.

    DATA: bdzei TYPE pbed-bdzei,

    entlu(1),

    plnmg(13),

    sernr(8),

    verid(4),

    rif(10),

    edatu(8).

    rif = wa_pbed1-rif.

    entlu = wa_pbed1-entlu.

    plnmg = wa_pbed1-plnmg.

    sernr = wa_pbed1-sernr.

    verid = wa_pbed1-verid.

    edatu = wa_pbed1-edatu.

    CONDENSE : bdzei,

    entlu,

    edatu,

    plnmg,

    sernr,

    verid,

    rif,

    edatu.

    CONCATENATE rif

    entlu

    edatu

    plnmg

    sernr

    verid

    INTO wa_text-tline SEPARATED BY space.

    CLEAR: bdzei,

    entlu,

    plnmg,

    sernr,

    verid,

    rif,

    edatu.

    ENDFORM. " con_fields1

    &----


    *& Form prepare_header

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM prepare_header.

    CLEAR: wa_header.

    REFRESH: i_header.

    wa_header-text = 'Reference'(t50).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Material number'(t02).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Requirements type'(t03).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Version number'(t04).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Indicator: version active'(t05).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Requirements plan number'(t01).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Plant'(t07).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Name of info structure - characteristic values'(t08).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Field name in the generated DDIC structure'(t09).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Version number in the information structure'(t10).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Account assignment category'(t11).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Special stock indicator'(t12).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Consumption posting'(t13).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Work breakdown structure element '(t14).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Item number in Sales Order'(t15).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Sales Order Number'(t16).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Reference type'(t52).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Date'(t17).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Time'(t18).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Indicator: valuation of special stock'(t19).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'MRP area'(t51).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'With no MRP'(t21).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    ENDFORM. " prepare_header

    &----


    *& Form prepare_header1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM prepare_header1.

    CLEAR: wa_header.

    REFRESH: i_header[].

    wa_header-text = 'Reference'(t50).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Period indicator'(t22).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Schedule line date'(t53).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Planned quantity'(t23).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'BOM explosion number'(t24).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    wa_header-text = 'Production version'(t25).

    APPEND wa_header TO i_header.

    CLEAR wa_header.

    ENDFORM. " prepare_header1

    &----


    *& Form header1

    &----


    • text

    ----


    FORM header1.

    CONCATENATE

    'Reference'(t50)

    'Material number'(t02)

    'Requirements type'(t03)

    'Version number'(t04)

    'Indicator: version active'(t05)

    'Requirements plan number'(t01)

    'Plant'(t07)

    'Name of info structure - characteristic values'(t08)

    'Field name in the generated DDIC structure'(t09)

    'Version number in the information structure'(t10)

    'Account assignment category'(t11)

    'Special stock indicator'(t12)

    'Consumption posting'(t13)

    'Work breakdown structure element '(t14)

    'Item number in Sales Order'(t15)

    'Sales Order Number'(t16)

    'Reference type'(t52)

    'Date'(t17)

    'Time'(t18)

    'Indicator: valuation of special stock'(t19)

    'Independent requirements pointer'(t20)

    'MRP area'(t51)

    'With no MRP'(t21)

    INTO wa_text-tline SEPARATED BY space.

    ENDFORM. " header1

    &----


    *& Form header2

    &----


    • text

    ----


    FORM header2.

    CONCATENATE

    'Reference'(t50)

    'Period indicator'(t22)

    'Schedule line date'(t53)

    'Planned quantity'(t23)

    'BOM explosion number'(t24)

    'Production version'(t25)

    INTO wa_text-tline SEPARATED BY space.

    ENDFORM. " header2

    &----


    *& Form get_data_pbid

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_data_pbid.

    • select the data from PBID table

    SELECT pbdnr

    berid

    FROM pbid

    INTO TABLE i_pbid

    FOR ALL ENTRIES IN i_pbim

    WHERE pbdnr = i_pbim-pbdnr.

    IF sy-subrc = 0.

    SORT i_pbid BY pbdnr.

    ENDIF.

    CLEAR: wa_pbid,

    wa_pbim.

    ENDFORM. " get_data_pbid

    &----


    *& Form DISP_DATA

    &----


    • text

    ----


    form DISP_DATA .

    format color = 2 intensified off.

    WRITE: 1 'Ref',

    10 'Mat num',

    18 'Requ type',

    27 'Ver num',

    36 'Indicator:vers act',

    47 'Requ plan num',

    60 'Plant',

    66 'Name of info stru',

    76 'DDIC str',

    86 'infor stru',

    100 'Acc assign cat',

    115 'Spec stock indicator',

    125 'Consumption posting',

    136 'Work breakdown stru ele ',

    146 'Item num in Sales Order',

    159 'Sales Ord Num',

    169 'Ref type',

    176 'Date',

    185 'Time',

    197 'Indicator: val of spe stock',

    217 'MRP area',

    228 'With no MRP'.

    write:/ .

    write :/1 'Reference',

    10 'Period indicator',

    22 'Schedule line date',

    35 'Planned quantity',

    48 'BOM explosion number',

    58 'Production version' .

    write :/ sy-uline(240).

    format color = 3.

    loop at i_pbim into wa_pbim.

    write:/1 v_count,

    10 wa_pbim-matnr,

    18 wa_pbim-bedae,

    27 wa_pbim-versb,

    36 wa_pbim-vervs,

    47 wa_pbim-pbdnr,

    60 wa_pbim-werks,

    66 wa_pbim-mcinc,

    76 wa_pbim-stfna,

    86 wa_pbim-vrsic,

    100 wa_pbim-knttp,

    115 wa_pbim-sobkz,

    125 wa_pbim-kzvbr,

    136 wa_pbim-pspel,

    146 wa_pbim-kdpos,

    159 wa_pbim-kdauf,

    169 wa_pbim-uebkz,

    176 wa_pbim-datlp,

    185 wa_pbim-uhrlp,

    197 wa_pbim-kzbws,

    217 wa_pbim-berid,

    228 wa_pbim-oplkz.

    endloop.

    loop at i_pbed1 into wa_pbed1.

    write:/ wa_pbed1-entlu,

    wa_pbed1-edatu,

    wa_pbed1-plnmg,

    wa_pbed1-sernr ,

    wa_pbed1-verid.

    endloop.

    endform. " DISP_DATA

    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.