Application Development 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: 

I need to develop the below code using ABAP 7.4 syntax.

0 Kudos

I need to develop the below code using ABAP 7.4 syntax. can anyone help me with the changes i need to make.

TYPES: BEGIN OF TY_CUST, CUSTNO(4) TYPE N, "Customer Number CNAME(20) TYPE C, "Customer Name CCITY(20) TYPE C, "Customer City END OF TY_CUST. DATA: T_CUST TYPE TABLE OF TY_CUST INITIAL SIZE 3, W_CUST TYPE TY_CUST.

W_CUST-CUSTNO = 1001. W_CUST-CNAME = 'Jayem Ltd.'. W_CUST-CCITY = 'Bangalore'. APPEND W_CUST TO T_CUST. W_CUST-CUSTNO = 1002. W_CUST-CNAME = 'HK Ltd.'. W_CUST-CCITY = 'Pune'. APPEND W_CUST TO T_CUST. W_CUST-CUSTNO = 1003. W_CUST-CNAME = 'SBH'. W_CUST-CCITY = 'Hyderabad'. APPEND W_CUST TO T_CUST. W_CUST-CUSTNO = 1004. W_CUST-CNAME = 'TCL Ltd.'. W_CUST-CCITY = 'Pune'. APPEND W_CUST TO T_CUST. * Copying data into another internal table with the same structure type DATA: T_CUST2 TYPE TABLE OF TY_CUST INITIAL SIZE 3, W_CUST2 TYPE TY_CUST. T_CUST2 = T_CUST.

WRITE: /3 'Data in T_CUST:'. SKIP. LOOP AT T_CUST INTO W_CUST. WRITE: /3 W_CUST-CUSTNO, W_CUST-CNAME, W_CUST-CCITY. ENDLOOP. SKIP 2. ULINE. WRITE: /3 'Data in T_CUST2:'. SKIP. LOOP AT T_CUST2 INTO W_CUST2. WRITE: /3 W_CUST2-CUSTNO, W_CUST2-CNAME, W_CUST2-CCITY. ENDLOOP. SKIP 2. ULINE. Copying data into another internal table with a different TYPES: BEGIN OF TY_CUSTNO, CUSTOMERNO(4) TYPE N, "Customer Number END OF TY_CUSTNO.

DATA: T_CUSTNO TYPE TABLE OF TY_CUSTNO, W_CUSTNO TYPE TY_CUSTNO.

T_CUSTNO = CORRESPONDING #( T_CUST MAPPING CUSTOMERNO = CUSTNO ). WRITE: /3 'Data in T_CUSTNO: Copying only customer numbers into another internal table'. SKIP. LOOP AT T_CUSTNO INTO W_CUSTNO. WRITE: /3 W_CUSTNO- CUSTOMERNO. ENDLOOP.

4 REPLIES 4

AlexGourdet
Community Manager
Community Manager
0 Kudos

Thank you for visiting SAP Community to get answers to your questions.

As you're looking to get most out of your community membership, please consider include a profile picture to increase user engagement & additional resources to your reference that can really benefit you:

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the best,

Alex

Sandra_Rossi
Active Contributor

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Be careful to post code on several lines...

akmal1216
Employee
Employee
0 Kudos

Hello,

It would be easy to read if you add your code clicking 'code' icon.

As for your code, you can use "Value", instead of appending structure to internal table.

Simultenously you can "Corresponding" to map entries of one internal table to another.

t_cust = VALUE #( ( custno = 1001 cname = 'Jayem Ltd.' ccity = 'Bangalore' )
( custno = 1002 cname = 'HK Ltd.' ccity = 'Pune' ) ).

Have a look to this blog as quick reference - ABAP 7.40 Quick Reference

matt
Active Contributor
0 Kudos

I need to develop the below code using ABAP 7.4 syntax. can anyone help me with the changes i need to make.

Why? If it works, just leave it as it is.