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

material no

0 Likes
2,265

{EDITED BY MODERATOR}

hi,

i want 5 series material no to be print as the output in report.

want can i do?

please give me a solution

following code:

TABLES : MARA.

TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ernam TYPE mara-ernam,
END OF ty_mara.

DATA : it_mara TYPE TABLE OF ty_mara,
wa_mara TYPE ty_mara.

SELECTION-SCREEN : BEGIN OF BLOCK 1.
PARAMETERS: p_matnr TYPE mara-matnr.
SELECTION-SCREEN END OF block 1.

START-OF-SELECTION.
SELECT matnr
ernam
FROM mara
INTO TABLE IT_mara
WHERE MATNR = P_MATNR.

END-OF-SELECTION.
LOOP AT IT_mara INTO WA_mara.

WRITE 😕 WA_mara-MATNR,
12 WA_mara-ERNAM.
ENDLOOP.

TOP-OF-PAGE.
WRITE : / 'material' COLOR 1,
12 'object' COLOR 2.

i want output starting with 5series means 500 5000 50000 500000

13 REPLIES 13
Read only

matt
Active Contributor
2,192

Asking for the third time..

Click on Actions and you can edit your question. Or if you want to add information, then click on Add a Comment - don't just keep asking the same question.

Read only

MateuszAdamus
Active Contributor
0 Likes
2,192

Hello alagu123

You can add a condition to your SELECT statement.

SELECT matnr ernam FROM mara INTO TABLE it_mara WHERE matnr LIKE '5%'.

Or change your LOOP statement to have a condition.

LOOP AT it_mara INTO wa_mara WHERE matnr CP '5*'.
" do write here
ENDLOOP.
Kind regards,
Mateusz
Read only

0 Likes
2,192

WITHOUT GIVEN A CONDITION WHETER IT DISPLAY OR NOT

Read only

0 Likes
2,192

If you want to have a condition on the selection screen then you might want to have a select-options instead of the parameter.

SELECTION-SCREEN BEGIN OF BLOCK 1.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF block 1.

START-OF-SELECTION.
SELECT matnr ernam
  FROM mara
  INTO TABLE it_mara
  WHERE matnr IN s_matnr.

Then if you enter "5*" on the selection screen you will only get the material numbers starting with 5.

Kind regards,
Mateusz
Read only

0 Likes
2,192

WOULD YOU TELL IT IN CLEAR.

enter "5*" on the selection screen how to write on selection-screen,

would you write and give it in select-option

Read only

0 Likes
2,192

If you want to hard-code it, then look at the code in my answer.

If you want to give the user an option to enter a value then check the comment about select-options.


Kind regards,
Mateusz
Read only

0 Likes
2,192

WOULD YOU TELL IT IN CLEAR.

enter "5*" on the selection screen how to write on selection-screen,

would you write and give it in select-option

Read only

0 Likes
2,192

I meant that user should enter 5* in the select options during the report's execution.

You can add a value to the select options by writing an INITIALIZATION event.

INITIALIZATION.
  APPEND INITIAL LINE TO s_matnr REFERENCE INTO DATA(ld_s_matnr).
  ld_s_matnr->sign = 'I'.
  ld_s_matnr->option = 'CP'.
  ld_s_matnr->low = '5*'.

Kind regards,

Mateusz

Read only

0 Likes
2,192


TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ernam TYPE mara-ernam,
END OF ty_mara.

DATA : it_mara TYPE TABLE OF ty_mara,
wa_mara TYPE ty_mara.

SELECTION-SCREEN : BEGIN OF BLOCK 1.
SELECT-OPTIONS : s_matnr FOR mara-matnr .
Selection-screen comment 2(11) text-002.
SELECTION-SCREEN END OF block 1 .

START-OF-SELECTION.
SELECT matnr
ernam
FROM mara
INTO TABLE it_mara
WHERE matnr IN s_matnr.

INITIALIZATION.
APPEND INITIAL LINE TO s_matnr REFERENCE INTO data(ld_s_matnr).
ld_s_matnr->sign = 'I'.
ld_s_matnr->option = 'CP'.
ld_s_matnr->low = '5*'.

END-OF-SELECTION.
LOOP AT it_mara INTO wa_mara .

WRITE 😕 WA_mara-MATNR,
12 WA_mara-ERNAM.
ENDLOOP.

i am getting error as data is unknown .please correct it.

Read only

0 Likes
2,192

You're missing the TABLES: mara. line.

You can also double click on the error message, it will move you to the line that is erroneous and you can try to figure out the error on your own. 🙂


Kind regards,
Mateusz
Read only

0 Likes
2,192


TABLES : MARA.

TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ernam TYPE mara-ernam,
END OF ty_mara.

DATA : it_mara TYPE TABLE OF ty_mara,
wa_mara TYPE ty_mara.



SELECTION-SCREEN : BEGIN OF BLOCK 1.
SELECT-OPTIONS : s_matnr FOR mara-matnr .
Selection-screen comment 2(11) text-002.
SELECTION-SCREEN END OF block 1 .

INITIALIZATION.
APPEND INITIAL LINE TO s_matnr REFERENCE INTO data(ld_s_matnr).
ld_s_matnr->sign = 'I'.
ld_s_matnr->option = 'CP'.
ld_s_matnr->low = '5*'.

START-OF-SELECTION.
SELECT matnr
ernam
FROM mara
INTO TABLE it_mara
WHERE matnr IN s_matnr.

END-OF-SELECTION.
LOOP AT it_mara INTO wa_mara .

WRITE 😕 WA_mara-MATNR,
12 WA_mara-ERNAM.
ENDLOOP.

TOP-OF-PAGE.
WRITE : / 'material' COLOR 1,
12 'object' COLOR 6.

and i have given a table mara but getting error.please correct it.

Read only

0 Likes
2,192

Change the INITIALIZATION part.

INITIALIZATION.
  s_matnr-sign = 'I'.
  s_matnr-option = 'CP'.
  s_matnr-low = '5*'.
  APPEND s_matnr.
Kind regards,
Mateusz
Read only

KatiNonhebel
Advisor
Advisor
0 Likes
2,192

alagu123 Please do not open several questions for the same content. I have deleted your other question. Should you wish, you can revise your question by selecting Actions, then Edit.

I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html

By adding a picture to your profile you encourage readers to respond:https://www.youtube.com/watch?v=46bt1juWUUM

Keep in mind, when you receive an answer that was helpful to you, accept it as best answer.

Good Luck

Kati - SAP Community Moderator