Skip to content

Latest commit

 

History

History
227 lines (162 loc) · 8.69 KB

File metadata and controls

227 lines (162 loc) · 8.69 KB

Tutorial 3: Implementing Development Workflow

Introduction

In Tutorial 1, you installed abapGit in your SAP system, and in Tutorial 2, you configured abapGit for your specific ABAP project. Now that you have successfully connected your SAP system to GitHub (Steps 1-65), it's time to implement a proper development workflow that leverages this integration to improve your development process.

Prerequisites

Before beginning this tutorial, ensure you have:

Workflow Overview

flowchart TD
    subgraph SAP System
        feature_branch["1. Create Feature Branch"]
        develop["2. Develop in SAP"]
        stage["3. Stage Changes"]
        commit["4. Commit and Push"]
    end
    
    subgraph GitHub
        pr["5. Create Pull Request"]
        review["6. Code Review"]
        merge["7. Merge to Main"]
    end
    
    subgraph SAP Sync
        pull["8. Pull Changes to SAP"]
    end
    
    feature_branch --> develop
    develop --> stage
    stage --> commit
    commit --> pr
    pr --> review
    review --> merge
    merge --> pull
    
    classDef sap fill:#f9f,stroke:#333,stroke-width:1px;
    classDef github fill:#bbf,stroke:#333,stroke-width:1px;
    classDef sync fill:#bfb,stroke:#333,stroke-width:1px;
    
    class feature_branch,develop,stage,commit sap;
    class pr,review,merge github;
    class pull sync;
Loading

This tutorial covers the implementation of a standard Git-based development workflow adapted for SAP development:

  1. Creating feature branches
  2. Making changes in SAP
  3. Committing and pushing to GitHub
  4. Creating pull requests
  5. Reviewing and merging code
  6. Pulling changes back to SAP

Step-by-Step Implementation

Step 12: Create a Feature Branch

Continuing from Tutorial 2 where you verified your GitHub integration in Steps 62-65, you'll now implement a proper branching strategy:

  1. Open abapGit by running transaction SE38 and executing program ZABAPGIT

  2. Navigate to your repository (the one you created in Steps 43-46 of Tutorial 2)

  3. Click on the branch icon in the abapGit toolbar (usually labeled "main")

  4. In the branch dialog, click Create New Branch

  5. Enter a feature branch name using a descriptive convention: feature/add-customer-list

  6. Select "Create from: main" to base your new branch on the main branch

  7. Click Create

  8. Verify that abapGit indicates you're now working on the new branch

Step 13: Implement a Feature in SAP

With your feature branch created in Steps 66-73, you'll now implement a new feature in SAP:

  1. Return to transaction SE80

  2. Navigate to your package Z_GITHUB_DEMO (created in Steps 32-35 of Tutorial 2)

  3. Right-click on the package and select Create > Program

  4. Enter a program name (e.g., Z_CUSTOMER_LIST)

  5. Add the following code:

    REPORT z_customer_list.
    
    TABLES: kna1. " Customer master data table
    
    PARAMETERS: p_limit TYPE i DEFAULT 10.
    
    START-OF-SELECTION.
      " Select customer data
      SELECT kunnr name1 land1 ort01
        FROM kna1
        INTO TABLE @DATA(lt_customers)
        UP TO @p_limit ROWS.
    
      " Display results
      WRITE: / 'Customer List', / '============'.
      LOOP AT lt_customers INTO DATA(ls_customer).
        WRITE: / 'ID:', ls_customer-kunnr, 
               'Name:', ls_customer-name1,
               'Country:', ls_customer-land1,
               'City:', ls_customer-ort01.
      ENDLOOP.
  6. Save and activate the program

Step 14: Commit and Push the Changes

After implementing your feature in Steps 74-79, you'll commit and push it to your feature branch:

  1. Return to abapGit by running transaction SE38 and executing program ZABAPGIT

  2. Navigate to your repository and verify that you're still on the feature/add-customer-list branch

  3. You should see your program Z_CUSTOMER_LIST with a new (non-staged) status

  4. Check the box next to your program to stage it

  5. Click the Stage button

  6. Enter a descriptive commit message: "Add customer list program for data reporting"

  7. Click Commit

  8. When prompted, enter your GitHub credentials

  9. Click Execute to complete the push

  10. Verify in abapGit that the push was successful

Step 15: Create a Pull Request

With your changes committed to the feature branch in Steps 80-89, it's time to create a pull request for code review:

  1. Open your web browser and navigate to your GitHub repository

  2. GitHub should show a notification about your recently pushed branch

  3. Click on the Compare & pull request button

  4. Enter a pull request title: "Add customer list program"

  5. In the description, provide details about your changes:

This pull request adds a new program to display customer information.

The program allows:
- Viewing customer master data
- Limiting the number of records displayed
- Displaying key information including ID, name, country, and city
  1. Click Create pull request

Step 16: Review and Merge the Pull Request

In a real-world scenario, another team member would review your changes. For this tutorial, you'll review and merge your own pull request:

  1. In GitHub, open the pull request you created in Steps 90-95

  2. Click on the "Files changed" tab to see the code changes

  3. Review the code changes, ensuring everything looks correct

  4. Add a comment to simulate a code review: "Code looks good. The field selection is appropriate for the report requirements."

  5. Click the Merge pull request button

  6. Click Confirm merge

  7. Verify that GitHub shows the pull request as merged

  8. Click on the Delete branch button to clean up the feature branch (optional)

Step 17: Pull Changes to SAP Main Branch

Now that your changes are merged into the main branch on GitHub in Steps 96-103, you need to update your SAP system:

  1. Return to abapGit by running transaction SE38 and executing program ZABAPGIT

  2. Navigate to your repository

  3. Switch back to the main branch by clicking on the branch icon and selecting "main"

  4. Click the Pull button to fetch the latest changes from GitHub

  5. abapGit will display the changes from your merged pull request

  6. Confirm the pull operation

  7. Verify that your Z_CUSTOMER_LIST program is now part of the main branch in your SAP system

Verification Checkpoint

Before concluding this tutorial, verify that:

  • Your feature branch was successfully created in GitHub
  • The new program was properly pushed to GitHub
  • The pull request was created, reviewed, and merged
  • Changes were successfully pulled back to the main branch in SAP
  • The program runs correctly in your SAP system

Common Issues and Solutions

Branch Switching Issues

Issue: "Local objects modified" error when switching branches

Solution:

  1. Commit or revert any local changes before switching branches
  2. Check if transport requests are open for modified objects
  3. Release or reassign transports if necessary

Merge Conflicts

Issue: Conflicts between your changes and the main branch

Solution:

  1. Pull the latest changes from the main branch before creating your feature branch
  2. If conflicts occur, resolve them in abapGit's merge tool
  3. For complex conflicts, consider manually resolving in SAP before committing

Transport Request Management

Issue: Objects locked in transport requests

Solution:

  1. Ensure objects are assigned to appropriate transport requests
  2. Release completed transport requests before switching branches
  3. Consider implementing a transport request strategy aligned with your branching strategy

Next Steps

Now that you have successfully implemented a development workflow in Steps 66-110, you're ready to proceed to the next phase of the integration:

In Tutorial 4, you'll learn how to implement automated testing, code quality checks, and validation processes to ensure your SAP developments meet quality standards before being deployed. This builds on the workflow established in this tutorial, adding automation to improve quality and efficiency.