ABAP development tools for Visual Studio Code provides an efficient and feature-rich set of tools for ABAP development within the ABAP Cloud development model. It brings modern ABAP development to your editor, enabling you to create, edit, debug, and manage ABAP artifacts directly in VS Code. You need to set up your development environment in Visual Studio Code and connect it to your ABAP system.
This tutorial focus on non-Agentic AI capabilities and do not need any coding agent extension in Visual Studio Code (for e.g: GitHub Copilot)
Step 1Add package as folder to workspace in VS Code
โ
You need to have a package created in ADT. This package can be added as a folder to workspace.
Open the Command Palette or Ctrl+Shift+P.Add Package
Type ABAP: Add Package as folder to Workspace
Search the package you have created in ADT.Search Package
Enter Workspace folder name.Folder Name
Folder is added to WorkspaceWorkspace Name
Step 2Logon to Destination
+
During any time if you have been logged out of system, you need to Log On to the Destination to continue the work by following options:
Right click on the Package which is added as a Folder to Workspace and choose “Log On to Destination”LogonOR
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Log On to DestinationLogon
Select the Destination. This will prompt to open the system in browser to enter the logon credentialsLogon
Step 3Open object
+
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Open ObjectOpen Object
Give the name of the object. E.g “I_Currency”. You can search for class, data definition.Search Object
You can analyse the opened object.View Object
Objects with unsaved backend changes are marked (L) โ they must be activated (Ctrl+F3) to become active in the system.
Step 4Create new Databse table
+
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Create New ABAP ObjectCreate Object
You can choose the object type that you want to create. Choose ‘Database Table’.choose Table
Choose the package name that was used in the previous step.choose Package
Enter the name of the Database Table ‘ZADT_Travel_###’to be created and press Enter to confirm.Table Name
Give a DescriptionTable Description
A new ‘Database Table’ will be created.
Copy the below code and replace it in the Database table. Replace ‘###’ with the unique number that you have given.
CDS
@EndUserText.label:'Table for ADT in VS Code'@AbapCatalog.enhancement.category:#NOT_EXTENSIBLE@AbapCatalog.tableCategory:#TRANSPARENT@AbapCatalog.deliveryClass:#A@AbapCatalog.dataMaintenance:#RESTRICTEDdefinetablezadt_travel_###{keyclient:abap.clntnotnull;keytravel_id:/dmo/travel_idnotnull;agency_id:/dmo/agency_id;customer_id:/dmo/customer_id;begin_date:/dmo/begin_date;end_date:/dmo/end_date;@Semantics.amount.currencyCode:'zadt_travel_###.currency_code'booking_fee:/dmo/booking_fee;@Semantics.amount.currencyCode:'zadt_travel_###.currency_code'total_price:/dmo/total_price;currency_code:/dmo/currency_code;description:/dmo/description;overall_status:/dmo/overall_status;created_by:abp_creation_user;created_at:abp_creation_tstmpl;local_last_changed_by:abp_locinst_lastchange_user;local_last_changed_at:abp_locinst_lastchange_tstmpl;last_changed_at:abp_lastchange_tstmpl;}
Step 5Check and Activate Object
+
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Check Object. This will run the syntax check on the opened object. The message ‘Running Syntax check’ appears in the Status barCheck Object
To Activate an object: open the Command PaletteCtrl+Shift+P and Type ABAP: Activate.Activate Object
You can also use Ctrl+F3. Activate icon is also available on top of the editor window.
Button Object
Step 6Create a data generator Class
+
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Create New ABAP ObjectCreate Object
You can choose the object type that you want to create. Choose ‘Class’.choose Object
Choose the package name that was used in the previous step.choose Package
Enter the name of the Class to be created and press Enter to confirm.Class Name
Give a DescriptionClass Description
Choose a Super Class and interface if required.Add Interface
A new ‘Class’ will be created.Class created
Copy the below code and replace it in the Class. Replace ‘###’ with the unique number that you have given.
ABAP
CLASSzcl_adt_travel_###DEFINITIONPUBLICFINALCREATE PUBLIC.PUBLIC SECTION.INTERFACESif_oo_adt_classrun.PROTECTED SECTION.PRIVATE SECTION.ENDCLASS.CLASSzcl_adt_travel_###IMPLEMENTATION.METHODif_oo_adt_classrun~main.DATA:group_idTYPE stringVALUE'###'.*cleardataDELETEFROMzadt_travel_###.*DELETEFROMzadt_travel_###."insert travel demo data
INSERTzadt_travel_###FROM(SELECTFROM/dmo/travelAStravelFIELDStravel~travel_idAStravel_id,travel~agency_idASagency_id,travel~customer_idAScustomer_id,travel~begin_dateASbegin_date,travel~end_dateASend_date,travel~booking_feeASbooking_fee,travel~total_priceAStotal_price,travel~currency_codeAScurrency_code,travel~descriptionASdescription,CASEtravel~status"[N(New) | P(Planned) | B(Booked) | X(Cancelled)]
WHEN'N'THEN'O'WHEN'P'THEN'O'WHEN'B'THEN'A'ELSE'X'ENDASoverall_status,travel~createdbyAScreated_by,travel~createdatAScreated_at,travel~lastchangedbyASlast_changed_by,travel~lastchangedatASlast_changed_at,travel~lastchangedatASlocal_last_changed_atORDER BYtravel_idUPTO10ROWS).COMMITWORK.out->write(| Demo data generated for table zadt_travel_{group_id}. |).ENDMETHOD.ENDCLASS.
To Format the document, right click on the class and choose Format Document.Format Class
Save and Activate the new Class by following Step 5.
Now execute your class by hitting F5 or Type ABAP: Open with ADT for Eclipse in the Command Palette.Execute Class
You will get a message ‘Demo data generated for table zadt_travel_###’ in the console.
Step 7Create new CDS View
+
Open the Command Palette or Ctrl+Shift+P.
Type ABAP: Create New ABAP ObjectCreate Object
You can choose the object type that you want to create. Choose ‘Data Definition’.choose CDS
Choose the package name that was used in the previous step.CDS Package
Enter the name of the Database Definition ‘ZI_ADT_Travel_###’to be created and press Enter to confirm.CDS Name
Give a Description
In the next step you can choose the reference object for the new CDS view to be buildReference Object
A new ‘Data Definition’ will be created.
Copy the below code and replace it in the CDS View Entity. Replace ‘###’ with the unique number that you have given.
CDS
@AbapCatalog.viewEnhancementCategory: [#NONE] @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'CDS view for ADT Tools' @Metadata.ignorePropagatedAnnotations: true define view entity ZI_ADT_Travel_### as select from ZADT_TRAVEL_### { key travel_id as TravelId, agency_id as AgencyId, customer_id as CustomerId, begin_date as BeginDate, end_date as EndDate, @semantics.amount.currencyCode: 'CurrencyCode' booking_fee as BookingFee, @semantics.amount.currencyCode: 'CurrencyCode' total_price as TotalPrice, currency_code as CurrencyCode, description as Description, overall_status as OverallStatus, created_by as CreatedBy, created_at as CreatedAt, local_last_changed_by as LocalLastChangedBy, local_last_changed_at as LocalLastChangedAt, last_changed_at as LastChangedAt }
ata-lang=cds>
CDS
@AbapCatalog.viewEnhancementCategory:[#NONE]@AccessControl.authorizationCheck:#NOT_REQUIRED@EndUserText.label:'CDS view for ADT Tools'@Metadata.ignorePropagatedAnnotations:truedefineviewentityZI_ADT_Travel_###asselectfromzadt_travel_###{keytravel_idasTravelId,agency_idasAgencyId,customer_idasCustomerId,begin_dateasBeginDate,end_dateasEndDate,@Semantics.amount.currencyCode:'CurrencyCode'booking_feeasBookingFee,@Semantics.amount.currencyCode:'CurrencyCode'total_priceasTotalPrice,casewhentotal_price>1000thencast(total_priceasabap.dec(16,2))*cast('0.90'asabap.dec(5,2))elsecast(total_priceasabap.dec(16,2))endasDiscountedFlightPrice,currency_codeasCurrencyCode,descriptionasDescription,overall_statusasOverallStatus,created_byasCreatedBy,created_atasCreatedAt,local_last_changed_byasLocalLastChangedBy,local_last_changed_atasLocalLastChangedAt,last_changed_atasLastChangedAt}
Savesave iconCtrl+S and activateactivate iconthe changes.
Now switch to Eclipse and create a unit test class for the CDS view above. In the Project Explorer, right-click on the CDS data definition ZI_ADT_Travel_### and select New ABAP Test Class from the context menu.
Enter the information below in the popup for the new ABAP Class that will be created and click on Next.
Name: ZCL_TEST_CDS_TRAVEL_###
Description: Test Class for CDS View ZI_ADT_Travel_###
The popup now displays the SQL dependencies for the CDS Test Double Framework.Dependencies
Click on Next 2 times and finally click on Finish.
Copy and replace the entire code inside the test class with the code below:
ABAP
"!@testing ZI_ADT_TRAVEL
CLASSltc_zi_adt_travelDEFINITIONFINALFORTESTINGRISKLEVELHARMLESSDURATIONSHORT.PRIVATE SECTION.CLASS-DATAenvironmentTYPE REF TOif_cds_test_environment.DATAtd_zadt_travelTYPE STANDARD TABLE OFzadt_travelWITHEMPTYKEY.DATAact_resultsTYPE STANDARD TABLE OFzi_adt_travelWITHEMPTYKEY.DATAexp_resultsTYPE STANDARD TABLE OFzi_adt_travelWITHEMPTYKEY."! In CLASS_SETUP, corresponding doubles and clone(s) for the CDS view under test and its dependencies are created.
CLASS-METHODSclass_setupRAISINGcx_static_check."! In CLASS_TEARDOWN, Generated database entities (doubles & clones) should be deleted at the end of test class execution.
CLASS-METHODSclass_teardown."! SETUP method creates a common start state for each test method,
"! clear_doubles clears the test data for all the doubles used in the test method before each test method execution.
METHODSsetupRAISINGcx_static_check."! In this method test data is inserted into the generated double(s) for test case
"! "Calculate DISCOUNTEDFLIGHTPRICE field"
METHODStd_calc_discountedflightprice."! In this method test data is inserted into the generated double(s) for test case
"! "When total_price > 1000"
METHODStd_total_price_gt_1000."! <strong>Test Case:</strong> Calculate DISCOUNTEDFLIGHTPRICE field <br><br>
"! Test calculation of DISCOUNTEDFLIGHTPRICE field.
"! <br><br> The results should be asserted with the actuals.
METHODScalc_discountedflightpriceFORTESTINGRAISINGcx_static_check."! <strong>Test Case:</strong> When total_price > 1000 <br><br>
"! Test a CDS View when the CASE condition When total_price > 1000 is satisfied.
"! <br><br> The results should be asserted with the actuals.
METHODStotal_price_gt_1000FORTESTINGRAISINGcx_static_check.ENDCLASS.CLASSltc_ZI_ADT_TRAVELIMPLEMENTATION.METHODclass_setup.environment=cl_cds_test_environment=>create(i_for_entity='ZI_ADT_TRAVEL_###').ENDMETHOD.METHODsetup.environment->clear_doubles().ENDMETHOD.METHODclass_teardown.environment->destroy().ENDMETHOD.METHODcalc_discountedflightprice.td_calc_discountedflightprice().SELECT*FROMzi_adt_travel_###INTOTABLE@act_results.cl_abap_unit_assert=>assert_equals(exp=lines(exp_results)act=lines(act_results)msg='Test Generated using AI: Recheck test data').LOOP AT exp_resultsINTODATA(exp_result).cl_abap_unit_assert=>assert_equals(exp=exp_result-discountedflightpriceact=act_results[sy-tabix]-discountedflightpricemsg='Test Generated using AI: Expected result for field DISCOUNTEDFLIGHTPRICE is incorrect. Recheck test data.').ENDLOOP.ENDMETHOD.METHODtd_calc_discountedflightprice." Prepare test data for 'ZADT_TRAVEL_###'
td_zadt_travel=VALUE#((client='100'travel_id='00000001'total_price='1200.00')).environment->insert_test_data(i_data=td_zadt_travel)." Prepare test data for 'zi_adt_travel_###'
exp_results=VALUE#((travelid='00000001'totalprice='1200.00'discountedflightprice='1080.00')).ENDMETHOD.METHODtotal_price_gt_1000.td_total_price_gt_1000().SELECT*FROMzi_adt_travel_###INTOTABLE@act_results.cl_abap_unit_assert=>assert_equals(exp=lines(exp_results)act=lines(act_results)msg='Test Generated using AI: Recheck test data').LOOP AT exp_resultsINTODATA(exp_result).cl_abap_unit_assert=>assert_equals(exp=exp_result-DiscountedFlightPriceact=act_results[sy-tabix]-DiscountedFlightPricemsg='Test Generated using AI: Expected result for field DiscountedFlightPrice is incorrect. Recheck test data.').ENDLOOP.ENDMETHOD.METHODtd_total_price_gt_1000." Prepare test data for 'ZADT_TRAVEL_###'
td_zadt_travel=VALUE#((client='100'travel_id='00000001'total_price='1200.00')).environment->insert_test_data(i_data=td_zadt_travel)." Prepare test data for 'zi_adt_travel_###'
exp_results=VALUE#((travelid='00000001'totalprice='1200.00'discountedflightprice='1080.00')).ENDMETHOD.ENDCLASS.
Savesave iconCtrl+S and activateactivate iconthe changes.
Now switch back to Visual Studio code and open the class zcl_test_cds_travel_###.clas.testclasses.abap file in editor as shown below.Open Testclass
Run the Unit Test by hitting Ctrl+Shift+F10 or Type ABAP: Run ABAP Unit Tests.Unit Test
The unit test results will be shown as below:Test Result
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 14
1. Add package as folder to workspace in VS Code2. Logon to Destination3. Open object4. Create new Databse table5. Check and Activate Object6. Create a data generator Class7. Create new CDS View8. Open with ADT for Eclipse9. Preview of a Fiori Application10. Create a new class method to display 10 records11. Debug a method12. Run ABAP Test Cockpit (ATC) Checks.13. Run Unit Test14. Test yourself
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.