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

Database Selections

Former Member
0 Likes
462

hi

can anybody help me to select data and write it to screen.

Objective:

To develop a simple ABAP Program to select data from Database Table.

Declarations

Tables: MARD.

Select-options: S_MATNR

Data: P_MATNR, P_WERKS, P_LGORT

Data: Define MAT_STR containing MATNR WERKS LGORT

Processing Flow

1. Select data from MARD into P_MATNR, P_WERKS, P_LGORT and write to screen

2. Select data from MARD into MAT_STR and write to screen

Thanks

1 ACCEPTED SOLUTION
Read only

rahulkavuri
Active Contributor
0 Likes
430

hi do u want to populate data in selection screen based on the values from MARD

ok try it this way

DATA: MAT_STR TYPE TABLE OF MARD WITH HEADER LINE.

" THIS WILL CREATE AN INTERNAL TABLE.

AT SELECTION-SCREEN OUTPUT.

SELECT MATNR

WERKS

LGORT

FROM MARD INTO (P_MATNR, P_WERKS, P_LGORT)

WHERE ( THIS DEPENDS ON UR CONDITION).

START-OF-SELECTION

SELECT * FROM MARD INTO TABLE MAT_STR.

END-OF-SELECTION.

LOOP AT MAT_STR.

WRITE:/ MAT_STR-MATNR, MAT_STR-WERKS.

ENDLOOP.

award points if found helpful

3 REPLIES 3
Read only

Former Member
0 Likes
430

Why don't you try writing the SELECTs yourself and post your code if you run into problems?

Rob

Read only

Former Member
0 Likes
430

Hi,

select matnr werks lgort into correesponding fields of table mat_str

where matnr in s_matnr.

loop at mat_str.

write:/ mat_str-matnr,

mat_str-werks,

mat_str-lgort.

endloop.

Regards

Subramanian

Read only

rahulkavuri
Active Contributor
0 Likes
431

hi do u want to populate data in selection screen based on the values from MARD

ok try it this way

DATA: MAT_STR TYPE TABLE OF MARD WITH HEADER LINE.

" THIS WILL CREATE AN INTERNAL TABLE.

AT SELECTION-SCREEN OUTPUT.

SELECT MATNR

WERKS

LGORT

FROM MARD INTO (P_MATNR, P_WERKS, P_LGORT)

WHERE ( THIS DEPENDS ON UR CONDITION).

START-OF-SELECTION

SELECT * FROM MARD INTO TABLE MAT_STR.

END-OF-SELECTION.

LOOP AT MAT_STR.

WRITE:/ MAT_STR-MATNR, MAT_STR-WERKS.

ENDLOOP.

award points if found helpful