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: 

SAP Developer Challenge – Open-Source (Week 3)

Mamikee
Developer Advocate
Developer Advocate

This discussion thread is to submit your solution for Week 3 of the May 2023 Developer Challenge - Open-Source ABAP 

Week 3 – ABAP Mustache https://github.com/sbcgua/abap_mustache

Mustache is a big deal in the web development world. It's a template syntax that doesn't use logic, letting you whip up a text template, stick some tags in there, and then swap those tags with dynamic content straight from your program – anything from individual values to full lists of values. Mustache is a real champ when it comes to generating bits of HTML (or entire pages), or pretty much any other text you want to template. Plus, the Mustache syntax is used in a huge number of languages.

Community member @atsy has put together an implementation of the mustache processor in ABAP, and named it - you guessed it - ABAP Mustache. So, for your third-week challenge, we're putting the spotlight on the ABAP Mustache project. Your challenge is to simply create an ABAP application which leverages this framework and outputs some data to the console. How you use ABAP Mustache is totally up to you - it's your chance to get creative and show us what you've got. Whether you want to keep it simple or go all out is completely your call. Once you're done, all you need to do is share your working ABAP code and give us a screenshot of the output in the console to prove you've nailed the challenge.

Resources  

 You will get credit for this weeks’ challenge by posting in this discussion thread the working ABAP code (a screen shot of your code, or via a link to your GitHub repo), and showing a screen shot of the output in the console. To give you an idea, here's an example screenshot below.

Mamikee_0-1684924887945.png

Have Fun 🤩

95 REPLIES 95

Hello!

I am trying to test a similar class to the example above. However, when I run it, I get the following dump:

"Access using a 'ZERO' object reference is not possible."

Below is my code:

guigas91_0-1684953935699.png

Does anyone here know what the problem could be?



It's your shortcut for newline - the c_nl that is the issue.  You never create an instance of that object you just type like cl_abap_char_utilities.  So, it's not a valid object reference. Change that to the full, original object or create a specific newline shortcut like so:

    DATA(c_nl) = cl_abap_char_utilities=>newline.

Have a look at the solution here: abap-hello-world/zcl_mustache_test_guilherme.clas.abap at main · jung-thomas/abap-hello-world · GitH...

0 Kudos

Thank you very much, Thomas! 👍

0 Kudos

Hello

How do you test the last class zcl_hello_dev_challenge_tpj in the browser ? Do you have created other objects than the class zcl_hello_dev_challenge_tpj?

Gurpreet_Jaspal
Participant
0 Kudos

Seems I have to convert the macros to methods to activate the classes in ABAP cloud environment. Working with chatGPT to achieve that. @thomas_jung pls let me know if there is any easy way I can use this project in ABAP cloud. 

GJASPALADL_0-1684987827690.png

 



0 Kudos

Hi,
Same issue with me. Most of us don't have on prem system. What can be done? 🤔

There are two versions of library available in GitHub via different branches. For ABAP Cloud make sure you are pulling the “steampunk” branch.

There are two versions of library available in GitHub via different branches. For ABAP Cloud make sure you are pulling the “steampunk” branch.

Saw this very late after making all the changes. 😑
Thanks for sharing this



Oh, you made ABAP Cloud version yourself 🙃 You should get bonus point 

-- Tomas --

Wasn't much to change tbh, Just a few macros changed as methods and "DEFINE FIELD" syntax to be modified with cl_abap_datadescr.
I actually gave up but was bored at work so thought to work with ChatGPT and made the changes. 😀



Gurpreet_Jaspal
Participant
0 Kudos

Hi Mamikee, 
Added my code zcl_scc0523_mustache_app to the same repo.
Below is the test result

GJASPALADL_0-1684996341915.png

 



Tomas_Buryanek
Active Contributor

Hello,

for this challenge someone already pulled ABAP Mustache repository into my instance of SAP BTP Cloud trial. But it was main branch which can not be activated on ABAP on Cloud (no SAP GUI). So I unlinked Z package, deleted objects and pulled "steampunk" branch of the repository, which is compatible with ABAP Cloud . Cheers mate 😉

Here is my implementation class. I tried to use ABAP Mustache to fill a demo "HTML e-mail template":

https://github.com/TBuryanek/SAP-Developer-Code-Challenge-Open-Source-ABAP/blob/main/src/zcl_tb_dev_...

And screenshot of console output:

abap_week3_challenge_result.png

Valid HTML page output:

abap_week3_challenge_result_html.png

-- Tomas --

0 Kudos

Awesome!

How do you run the class result in the browser and view the HTML result?


Thanks

0 Kudos

For my test I just copy pasted the code from console to *.html file in notepad. But I am sure there are would be some better ways.

-- Tomas --

0 Kudos

thank you very much!

NooruBohra
Participant

Here's my submission.

bohranooru17/May2023DeveloperChallenge (github.com) - look for "src/yd215_opensrc_wk3.clas.abap"

OpnSrcWk3.png

Hello, Mamikee!

Here's my code:

guigas91_0-1685037540605.png

My repository with the code for this challenge: https://github.com/ggarcia-de-souza/helloWorldClassAbap.git

0 Kudos

Tears for Fears and A-Ha are two of my favorites from the 80s.

Cheers,

Rich

KjetilKilhavn
Active Contributor

Always nice to learn something new, and after a small improvement of the ABAP Mustache render class (https://github.com/sbcgua/abap_mustache/pull/12) I got this:

kjetil_kilhavn_0-1685056501616.png

--
Kjetil Kilhavn (Vettug AS) - ABAP developer since Feb 2000, but will probably never be a Rockstar developer

UweFetzer_se38
Active Contributor

My Code 

week3_code.png

Result

Week3_output.png

Ah, you're killin me bro!  LOL

0 Kudos

😁

Florian
Active Contributor

Here we go.. just toa make the point. You need an onprem, because it is not Cloud Ready! Make sure to take the correct branch --> https://github.com/sbcgua/abap_mustache/tree/steampunk

Florian_0-1685099872758.png

 

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Actually, it is cloud ready. You need to pull the steampunk branch, not the main branch if on an ABAP Cloud based system. 

Florian
Active Contributor
0 Kudos

Hey Thomas, looks like I did not make the point.. I just wanted to make the point, that the Main-Branch is not cloud ready.

former_member139139
Discoverer

Hi,

Here is my code and Output  - Git Repo Link .

 

chiranjeevig_1-1685111200997.pngchiranjeevig_2-1685111247202.png

 

Sadullah
Participant

Awesome....  🙂

0 Kudos

Thanks for your kind words, I try to follow you experts 🤓

Ruthiel
Product and Topic Expert
Product and Topic Expert

Great Challenge!

Ruthiel_0-1685120644456.png

I had issues when I tried to run this solution on an instance of ABAP Environment!
I had to change a couple of instructions that are not ready for the new version of ABAP: ABAP for Cloud Development.

 

Finally it worked!

barisguler
Participant

Hello all, here is my 3rd week challenge 

Week 3 Code 

barisguler_0-1685134276334.png

 

Sadullah
Participant
0 Kudos

I also love app development in Angular and today recognize that it uses mustache in templates with double curly braces, called interpolation in Angular.