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

Executing Three standard Table in one code using radio button option

0 Likes
1,324

Hi Everyone,

I need to print the some of the field value in standard table, Table which I used here is MARA, MARC and MBEW.

I want to display the field values with correct spacing. When I click mara radio button it should execute the particular field which is in mara, the same way i need to execute other two tables.

Below is my code.

REPORT ZPR_BASIC_REPORT_ASSIGNMENT1.
"Table declaration
TABLES: MARA,
MARC,
MBEW.

"type declaration
TYPES: BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
BISMT TYPE BISMT,
MEINS TYPE MEINS,
END OF TY_MARA.

TYPES: BEGIN OF TY_MARC,
MATNR TYPE MATNR,
WERKS TYPE WERKS,
DISMM TYPE DISMM,
DISPO TYPE DISPO,
KZDIE TYPE KZDIE,
KZPPV TYPE KZPPV,
MPDAU TYPE MPDAU,
END OF TY_MARC.

TYPES: BEGIN OF TY_MBEW,
MATNR TYPE MATNR,
BWKEY TYPE BWKEY,
BWTAR TYPE BWTAR_D,
STPRV TYPE STPRV,
LAEPR TYPE LAEPR,
ZKPRS TYPE DZKPRS,
ZKDAT TYPE DZKDAT,
END OF TY_MBEW.

" Data and Work Area
DATA: T_MARA TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA,
T_MARC TYPE STANDARD TABLE OF TY_MARC,
WA_MARC TYPE TY_MARC,
T_MBEW TYPE STANDARD TABLE OF TY_MBEW,
WA_MBEW TYPE TY_MBEW.


"selection screen
SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME TITLE TEXT-001.


SELECT-OPTIONS s_matnr FOR mara-matnr OBLIGATORY.
SELECT-OPTIONS WERKS FOR MARC-WERKS.
SELECT-OPTIONS BWKEY FOR MBEW-BWKEY.
SELECT-OPTIONS BWTAR FOR MBEW-BWTAR.
SELECTION-SCREEN END OF BLOCK part1.

SELECTION-SCREEN BEGIN OF BLOCK part2 WITH FRAME TITLE TEXT-002.

PARAMETERS: r1 RADIOBUTTON GROUP rad1,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK part2.

IF R1 IS NOT INITIAL.
SELECT MATNR
MTART
MBRSH
BISMT
MEINS
FROM mara INTO TABLE T_mara
WHERE matnr IN s_matnr.
perform put_mara.
perform put_output.
perform top-of-page.

ELSEIF R2 IS NOT INITIAL.
SELECT MATNR
WERKS
DISMM
DISPO
KZDIE
KZPPV
MPDAU
FROM marc INTO TABLE t_marc
WHERE matnr IN s_matnr.
perform put_output1.

ELSE.
SELECT MATNR
BWKEY
BWTAR
STPRV
LAEPR
ZKPRS
ZKDAT
FROM mbew INTO TABLE t_mbew
WHERE matnr IN s_matnr.
perform put_output2.
ENDIF.

START-OF-SELECTION.
PERFORM put_mara.
END-OF-SELECTION.
PERFORM put_output.
Top-of-page.
perform top-of-page.

FORM put_mara.
IF sy-subrc <> 0.
MESSAGE 'Material Doesn''t Exist.' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.

FORM put_output.
IF T_mara IS NOT INITIAL.
LOOP AT T_mara INTO wa_mara.
"Control break statement – it will display one time at first line
AT FIRST.
WRITE: /3 'Material No',
25 'Material Type',
40 'Industry Sector',
70 'Old material number',
100 'Base Unit of Measure'.
ULINE.
SKIP.
ENDAT.
WRITE: / wa_mara-matnr,
25 wa_mara-MTART,
40 wa_mara-MBRSH,
70 wa_mara-BISMT,
100 wa_mara-MEINS.
"Control break statement – it will display one time at last line
AT LAST.
ULINE.
WRITE: /15 '~~End of Material Display~~'.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.
START-OF-SELECTION.
PERFORM put_marc.
END-OF-SELECTION.
PERFORM put_output1.


FORM put_marc.
IF sy-subrc <> 0.
MESSAGE 'Material Doesn''t Exist.' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
FORM put_output1.
IF T_marc IS NOT INITIAL.
LOOP AT T_marc INTO wa_marc.
"Control break statement – it will display one time at first line
AT FIRST.
WRITE: /3 'Material No',
25 'Plant',
40 'MRP Type',
50 'MRP Controller',
90 'Indicator: MRP controller is buyer',
100 'Indicator for inspection plan',
130 'Mean inspection duration'.
ULINE.
SKIP.
ENDAT.

WRITE: / wa_marc-matnr,
25 wa_marc-WERKS,
40 wa_marc-DISMM,
50 wa_marc-DISPO,
90 wa_marc-KZDIE,
100 wa_marc-KZPPV,
130 wa_marc-MPDAU.
"Control break statement – it will display one time at last line
AT LAST.
ULINE.
WRITE: /15 '~~End of Material Display~~'.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.

START-OF-SELECTION. PERFORM put_mbew.
END-OF-SELECTION. PERFORM put_output2.

FORM put_mbew.
IF sy-subrc <> 0.
MESSAGE 'Material Doesn''t Exist.' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
FORM put_output2.
IF T_mbew IS NOT INITIAL.
LOOP AT T_mbew INTO wa_mbew.
"Control break statement – it will display one time at first line
AT FIRST.
WRITE: /3 'Material No',
35 'Valuation Area',
40 'Valuation Type',
60 'Previous price',
100 'Date of the last price change',
70 'Future price',
130 'Date as of which the price is valid'.
ULINE.
SKIP.
ENDAT.
WRITE: / wa_mbew-matnr,
35 wa_mbew-BWKEY,
40 wa_mbew-BWTAR ,
60 wa_mbew-STPRV,
100 wa_mbew-LAEPR,
70 wa_mbew-ZKPRS,
130 wa_mbew-ZKDAT.
"Control break statement – it will display one time at last line
AT LAST.
ULINE.
WRITE: /15 '~~End of Material Display~~'.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.
Top-OF-PAGE.
FORM top-of-page.
WRITE:/ 'BASIC REPORT CONTAINING GENERAL MATERIAL DATA FROM THE STANDARD TABLE'.
ULINE.
ENDFORM.

Using this code I'm getting an over looping output, Output is not expected .Please help me on this issue.

3 REPLIES 3
Read only

abo
Active Contributor
1,156

Please use the CODE tag to format the code: it is easier to read.

Read only

matt
Active Contributor
1,156

As Sandra Rossi said here: https://answers.sap.com/questions/13485280/select-option-2.html?childToView=13485438 used the "code" button in the question editor to paste code!

Until you do that, I'm not looking further at your question.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,156

I don't understand the question. What is the "MARA radio button"? I only see R1, R2, R3. (of the importance of the naming...)